Skip to content

Commit

Permalink
Updated README and allowed a simpley syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mhart committed Jun 21, 2012
1 parent 92d4e9e commit e15f787
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ':')
//
nconf.env('__');
// Get the value of the env variable 'database__host'
var dbHost = nconf.get('database:host');

//
// Or use both options
//
nconf.env({
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
Expand Down
4 changes: 3 additions & 1 deletion lib/nconf/stores/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ var Env = exports.Env = function (options) {
this.readOnly = true;
this.filter = options.filter || [];
this.separator = options.separator || '';
// Backwards compatibility
if (options instanceof Array) {
this.filter = options;
}
if (typeof(options) === 'string') {
this.separator = options;
}
};

// Inherit from the Memory store
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/scripts/nconf-nested-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
*
*/

var nconf = require('../../../lib/nconf').env({separator: '_'});
var nconf = require('../../../lib/nconf').env('_');

process.stdout.write(nconf.get('SOME:THING'));

0 comments on commit e15f787

Please sign in to comment.