Skip to content

Commit

Permalink
[fix] Fixed regression introduced by #98.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Nov 26, 2014
1 parent 8d5fb25 commit 0934255
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/nconf/stores/env.js
Expand Up @@ -21,9 +21,14 @@ var Env = exports.Env = function (options) {
options = options || {};
this.type = 'env';
this.readOnly = true;
this.match = options.match
this.whitelist = options.whitelist || [];
this.separator = options.separator || '';

if (typeof options.match === 'function'
&& typeof options !== 'string') {
this.match = options.match;
}

if (options instanceof Array) {
this.whitelist = options;
}
Expand Down Expand Up @@ -57,15 +62,16 @@ Env.prototype.loadEnv = function () {
return key.match(self.match) || self.whitelist.indexOf(key) !== -1
}
else if (self.match) {
return key.match(self.match)
return key.match(self.match);
}
else {
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]);
} else {
}
else {
self.set(key, process.env[key]);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/provider-test.js
Expand Up @@ -12,7 +12,7 @@ var assert = require('assert'),
vows = require('vows'),
helpers = require('./helpers'),
nconf = require('../lib/nconf');

var fixturesDir = path.join(__dirname, 'fixtures'),
mergeFixtures = path.join(fixturesDir, 'merge'),
files = [path.join(mergeFixtures, 'file1.json'), path.join(mergeFixtures, 'file2.json')],
Expand Down Expand Up @@ -123,7 +123,7 @@ vows.describe('nconf/provider').addBatch({
.add('file2', {type: 'file', file: files[1]}),
"should respect the hierarchy": function(provider) {
var merged = provider.load();

helpers.assertMerged(null, merged);
assert.equal(merged.foo.bar, 'baz');
assert.equal(merged.candy.something, 'file1');
Expand Down

0 comments on commit 0934255

Please sign in to comment.