From 120f5f0a4ba8b34d948921bdbc69388540f835bc Mon Sep 17 00:00:00 2001 From: joaoafrmartins Date: Fri, 10 Jan 2014 00:26:07 +0000 Subject: [PATCH] added documentation --- README.md | 5 +++-- lib/nconf/stores/env.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c0b6815..5126c4f 100644 --- a/README.md +++ b/README.md @@ -190,11 +190,12 @@ Responsible for loading the values parsed from `process.env` into the configurat var dbHost = nconf.get('database:host'); // - // Or use both options + // Or use all options // nconf.env({ separator: '__', - whitelist: ['database__host', 'only', 'load', 'these', 'values'] + match: /^whatever_matches_this_will_be_whitelisted/ + whitelist: ['database__host', 'only', 'load', 'these', 'values', 'if', 'whatever_doesnt_match_but_is_whitelisted_gets_loaded_too'] }); var dbHost = nconf.get('database:host'); ``` diff --git a/lib/nconf/stores/env.js b/lib/nconf/stores/env.js index b3227c7..3d7a7f9 100644 --- a/lib/nconf/stores/env.js +++ b/lib/nconf/stores/env.js @@ -53,7 +53,9 @@ Env.prototype.loadEnv = function () { this.readOnly = false; Object.keys(process.env).filter(function (key) { - if(self.match) { + if(self.match && self.whitelist.length) { + return key.match(self.match) || self.whitelist.indexOf(key) !== -1 + } else if (self.match) { return key.match(self.match) } else { return !self.whitelist.length || self.whitelist.indexOf(key) !== -1