Added test and updated docs
This commit is contained in:
parent
8921d0502e
commit
92d4e9ea14
3 changed files with 23 additions and 0 deletions
|
@ -159,6 +159,14 @@ Responsible for loading the values parsed from `process.env` into the configurat
|
||||||
// Can optionally also be an Array of values to limit process.env to.
|
// Can optionally also be an Array of values to limit process.env to.
|
||||||
//
|
//
|
||||||
nconf.env(['only', 'load', 'these', 'values', 'from', 'process.env']);
|
nconf.env(['only', 'load', 'these', 'values', 'from', 'process.env']);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Can also specify a separator for nested keys (instead of the default ':')
|
||||||
|
//
|
||||||
|
nconf.env({
|
||||||
|
separator: '__',
|
||||||
|
filter: ['database__host', 'only', 'load', 'these', 'values', 'from', 'process.env']
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Literal
|
### Literal
|
||||||
|
|
11
test/fixtures/scripts/nconf-nested-env.js
vendored
Normal file
11
test/fixtures/scripts/nconf-nested-env.js
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* nconf-nested-env.js: Test fixture for env with nested keys.
|
||||||
|
*
|
||||||
|
* (C) 2012, Nodejitsu Inc.
|
||||||
|
* (C) 2012, Michael Hart
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
var nconf = require('../../../lib/nconf').env({separator: '_'});
|
||||||
|
|
||||||
|
process.stdout.write(nconf.get('SOME:THING'));
|
|
@ -60,6 +60,10 @@ vows.describe('nconf/provider').addBatch({
|
||||||
script: path.join(fixturesDir, 'scripts', 'nconf-hierarchical-file-argv.js'),
|
script: path.join(fixturesDir, 'scripts', 'nconf-hierarchical-file-argv.js'),
|
||||||
argv: ['--something', 'foobar'],
|
argv: ['--something', 'foobar'],
|
||||||
env: { SOMETHING: true }
|
env: { SOMETHING: true }
|
||||||
|
}),
|
||||||
|
"when 'env' is set to true with a nested separator": helpers.assertSystemConf({
|
||||||
|
script: path.join(fixturesDir, 'scripts', 'nconf-nested-env.js'),
|
||||||
|
env: { SOME_THING: 'foobar' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue