diff --git a/README.md b/README.md index f8b583a..b9c8aaf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/nconf/stores/env.js b/lib/nconf/stores/env.js index f5e541c..1aacd47 100644 --- a/lib/nconf/stores/env.js +++ b/lib/nconf/stores/env.js @@ -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 diff --git a/test/fixtures/scripts/nconf-nested-env.js b/test/fixtures/scripts/nconf-nested-env.js index 2752c8c..cfc3365 100644 --- a/test/fixtures/scripts/nconf-nested-env.js +++ b/test/fixtures/scripts/nconf-nested-env.js @@ -6,6 +6,6 @@ * */ -var nconf = require('../../../lib/nconf').env({separator: '_'}); +var nconf = require('../../../lib/nconf').env('_'); process.stdout.write(nconf.get('SOME:THING'));