Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoafrmartins committed Jan 10, 2014
1 parent 681fd2f commit 120f5f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -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');
```
Expand Down
4 changes: 3 additions & 1 deletion lib/nconf/stores/env.js
Expand Up @@ -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
Expand Down

0 comments on commit 120f5f0

Please sign in to comment.