From 92d4e9ea14172ee2bdd418b24d271d04e9954c74 Mon Sep 17 00:00:00 2001 From: Michael Hart Date: Thu, 21 Jun 2012 17:04:06 +1000 Subject: [PATCH] Added test and updated docs --- README.md | 8 ++++++++ test/fixtures/scripts/nconf-nested-env.js | 11 +++++++++++ test/provider-test.js | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 test/fixtures/scripts/nconf-nested-env.js diff --git a/README.md b/README.md index 5fa3348..f8b583a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/fixtures/scripts/nconf-nested-env.js b/test/fixtures/scripts/nconf-nested-env.js new file mode 100644 index 0000000..2752c8c --- /dev/null +++ b/test/fixtures/scripts/nconf-nested-env.js @@ -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')); diff --git a/test/provider-test.js b/test/provider-test.js index 158b40c..63cb6f1 100644 --- a/test/provider-test.js +++ b/test/provider-test.js @@ -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' } }) } }