confe
v0.0.1
Published
Simple config file management.
Downloads
2
Maintainers
Readme
confe
Simple config file management.
Top level keys that include the special "extends" key will include, and overwrite, keys from that top level key. This process is recursive.
The two required arguments can be set via the enviroment variables;
- NODE_CONFIG_FILE
- NODE_ENV
or provided inline (in order);
- path to config file
- top level key name
Installation
$ npm install -g confe
Examples
The following examples show you how to use confe.
var confe = require('confe');
// example config file (config.json)
/*
{
"dev": {"email": "[email protected]", "google-key": "abcxyz"}
, "local-developer1": {"extends": "dev", "email": "[email protected]"}
, "local-developer2": {"extends": "dev", "email": "[email protected]", "google-key": "123"}
, "prod": {"email": "[email protected]", "google-key": "asdf4567"}
}
*/
var config = confe('./config.json', 'dev');
// { email: '[email protected]', 'google-key': 'abcxyz' }
// or
var config = confe('./config.json', 'local-developer1');
// { email: '[email protected]', 'google-key': 'abcxyz', extends: 'dev' }
// or
var config = confe('./config.json', 'local-developer2');
// { email: '[email protected]', 'google-key': '123', extends: 'dev' }
// or
// NODE_CONFIG_FILE=/path/to/config.json
// NODE_ENV=prod
var config = confe();
// { email: '[email protected]', 'google-key': 'asdf4567' }
Running tests
$ npm test