Changed to as it's more accurate

This commit is contained in:
Michael Hart 2012-06-21 18:04:37 +10:00
parent e15f787940
commit 3c08fad1c9
3 changed files with 7 additions and 7 deletions

View file

@ -172,7 +172,7 @@ Responsible for loading the values parsed from `process.env` into the configurat
// //
nconf.env({ nconf.env({
separator: '__', separator: '__',
filter: ['database__host', 'only', 'load', 'these', 'values'] whitelist: ['database__host', 'only', 'load', 'these', 'values']
}); });
var dbHost = nconf.get('database:host'); var dbHost = nconf.get('database:host');
``` ```

View file

@ -21,10 +21,10 @@ var Env = exports.Env = function (options) {
options = options || {}; options = options || {};
this.type = 'env'; this.type = 'env';
this.readOnly = true; this.readOnly = true;
this.filter = options.filter || []; this.whitelist = options.whitelist || [];
this.separator = options.separator || ''; this.separator = options.separator || '';
if (options instanceof Array) { if (options instanceof Array) {
this.filter = options; this.whitelist = options;
} }
if (typeof(options) === 'string') { if (typeof(options) === 'string') {
this.separator = options; this.separator = options;
@ -52,7 +52,7 @@ Env.prototype.loadEnv = function () {
this.readOnly = false; this.readOnly = false;
Object.keys(process.env).filter(function (key) { 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) { }).forEach(function (key) {
if (self.separator) { if (self.separator) {
self.set(common.key.apply(common, key.split(self.separator)), process.env[key]); self.set(common.key.apply(common, key.split(self.separator)), process.env[key]);

View file

@ -16,8 +16,8 @@ vows.describe('nconf/stores/env').addBatch({
"should have the correct methods defined": function (env) { "should have the correct methods defined": function (env) {
assert.isFunction(env.loadSync); assert.isFunction(env.loadSync);
assert.isFunction(env.loadEnv); assert.isFunction(env.loadEnv);
assert.isArray(env.filter); assert.isArray(env.whitelist);
assert.lengthOf(env.filter, 0); assert.lengthOf(env.whitelist, 0);
assert.equal(env.separator, ''); assert.equal(env.separator, '');
} }
} }