Updated README and allowed a simpley syntax

master
Michael Hart 2012-06-21 17:18:22 +10:00
parent 92d4e9ea14
commit e15f787940
3 changed files with 14 additions and 4 deletions

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