Updated README and allowed a simpley syntax
This commit is contained in:
parent
92d4e9ea14
commit
e15f787940
3 changed files with 14 additions and 4 deletions
10
README.md
10
README.md
|
@ -163,10 +163,18 @@ Responsible for loading the values parsed from `process.env` into the configurat
|
||||||
//
|
//
|
||||||
// Can also specify a separator for nested keys (instead of the default ':')
|
// Can also specify a separator for nested keys (instead of the default ':')
|
||||||
//
|
//
|
||||||
|
nconf.env('__');
|
||||||
|
// Get the value of the env variable 'database__host'
|
||||||
|
var dbHost = nconf.get('database:host');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Or use both options
|
||||||
|
//
|
||||||
nconf.env({
|
nconf.env({
|
||||||
separator: '__',
|
separator: '__',
|
||||||
filter: ['database__host', 'only', 'load', 'these', 'values', 'from', 'process.env']
|
filter: ['database__host', 'only', 'load', 'these', 'values']
|
||||||
});
|
});
|
||||||
|
var dbHost = nconf.get('database:host');
|
||||||
```
|
```
|
||||||
|
|
||||||
### Literal
|
### Literal
|
||||||
|
|
|
@ -23,10 +23,12 @@ var Env = exports.Env = function (options) {
|
||||||
this.readOnly = true;
|
this.readOnly = true;
|
||||||
this.filter = options.filter || [];
|
this.filter = options.filter || [];
|
||||||
this.separator = options.separator || '';
|
this.separator = options.separator || '';
|
||||||
// Backwards compatibility
|
|
||||||
if (options instanceof Array) {
|
if (options instanceof Array) {
|
||||||
this.filter = options;
|
this.filter = options;
|
||||||
}
|
}
|
||||||
|
if (typeof(options) === 'string') {
|
||||||
|
this.separator = options;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Inherit from the Memory store
|
// Inherit from the Memory store
|
||||||
|
|
2
test/fixtures/scripts/nconf-nested-env.js
vendored
2
test/fixtures/scripts/nconf-nested-env.js
vendored
|
@ -6,6 +6,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var nconf = require('../../../lib/nconf').env({separator: '_'});
|
var nconf = require('../../../lib/nconf').env('_');
|
||||||
|
|
||||||
process.stdout.write(nconf.get('SOME:THING'));
|
process.stdout.write(nconf.get('SOME:THING'));
|
||||||
|
|
Loading…
Reference in a new issue