Updated README and allowed a simpley syntax

This commit is contained in:
Michael Hart 2012-06-21 17:18:22 +10:00
parent 92d4e9ea14
commit e15f787940
3 changed files with 14 additions and 4 deletions
README.md
lib/nconf/stores
test/fixtures/scripts

View file

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

View file

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

View file

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