Changed to as it's more accurate
This commit is contained in:
parent
e15f787940
commit
3c08fad1c9
3 changed files with 7 additions and 7 deletions
|
@ -172,7 +172,7 @@ Responsible for loading the values parsed from `process.env` into the configurat
|
|||
//
|
||||
nconf.env({
|
||||
separator: '__',
|
||||
filter: ['database__host', 'only', 'load', 'these', 'values']
|
||||
whitelist: ['database__host', 'only', 'load', 'these', 'values']
|
||||
});
|
||||
var dbHost = nconf.get('database:host');
|
||||
```
|
||||
|
|
|
@ -21,10 +21,10 @@ var Env = exports.Env = function (options) {
|
|||
options = options || {};
|
||||
this.type = 'env';
|
||||
this.readOnly = true;
|
||||
this.filter = options.filter || [];
|
||||
this.whitelist = options.whitelist || [];
|
||||
this.separator = options.separator || '';
|
||||
if (options instanceof Array) {
|
||||
this.filter = options;
|
||||
this.whitelist = options;
|
||||
}
|
||||
if (typeof(options) === 'string') {
|
||||
this.separator = options;
|
||||
|
@ -52,7 +52,7 @@ Env.prototype.loadEnv = function () {
|
|||
|
||||
this.readOnly = false;
|
||||
Object.keys(process.env).filter(function (key) {
|
||||
return !self.filter.length || self.filter.indexOf(key) !== -1;
|
||||
return !self.whitelist.length || self.whitelist.indexOf(key) !== -1;
|
||||
}).forEach(function (key) {
|
||||
if (self.separator) {
|
||||
self.set(common.key.apply(common, key.split(self.separator)), process.env[key]);
|
||||
|
|
|
@ -16,8 +16,8 @@ vows.describe('nconf/stores/env').addBatch({
|
|||
"should have the correct methods defined": function (env) {
|
||||
assert.isFunction(env.loadSync);
|
||||
assert.isFunction(env.loadEnv);
|
||||
assert.isArray(env.filter);
|
||||
assert.lengthOf(env.filter, 0);
|
||||
assert.isArray(env.whitelist);
|
||||
assert.lengthOf(env.whitelist, 0);
|
||||
assert.equal(env.separator, '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue