[fix] Fixed regression introduced by #98.
This commit is contained in:
parent
8d5fb25701
commit
09342555ba
2 changed files with 11 additions and 5 deletions
|
@ -21,9 +21,14 @@ var Env = exports.Env = function (options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.type = 'env';
|
this.type = 'env';
|
||||||
this.readOnly = true;
|
this.readOnly = true;
|
||||||
this.match = options.match
|
|
||||||
this.whitelist = options.whitelist || [];
|
this.whitelist = options.whitelist || [];
|
||||||
this.separator = options.separator || '';
|
this.separator = options.separator || '';
|
||||||
|
|
||||||
|
if (typeof options.match === 'function'
|
||||||
|
&& typeof options !== 'string') {
|
||||||
|
this.match = options.match;
|
||||||
|
}
|
||||||
|
|
||||||
if (options instanceof Array) {
|
if (options instanceof Array) {
|
||||||
this.whitelist = options;
|
this.whitelist = options;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +62,7 @@ Env.prototype.loadEnv = function () {
|
||||||
return key.match(self.match) || self.whitelist.indexOf(key) !== -1
|
return key.match(self.match) || self.whitelist.indexOf(key) !== -1
|
||||||
}
|
}
|
||||||
else if (self.match) {
|
else if (self.match) {
|
||||||
return key.match(self.match)
|
return key.match(self.match);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return !self.whitelist.length || self.whitelist.indexOf(key) !== -1
|
return !self.whitelist.length || self.whitelist.indexOf(key) !== -1
|
||||||
|
@ -65,7 +70,8 @@ Env.prototype.loadEnv = function () {
|
||||||
}).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]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
self.set(key, process.env[key]);
|
self.set(key, process.env[key]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue