Added test and updated docs

This commit is contained in:
Michael Hart 2012-06-21 17:04:06 +10:00
parent 8921d0502e
commit 92d4e9ea14
3 changed files with 23 additions and 0 deletions

View file

@ -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.
//
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

View 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'));

View file

@ -60,6 +60,10 @@ vows.describe('nconf/provider').addBatch({
script: path.join(fixturesDir, 'scripts', 'nconf-hierarchical-file-argv.js'),
argv: ['--something', 'foobar'],
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' }
})
}
}