added regexp filtering to nconf env store
This commit is contained in:
parent
022b9bc507
commit
681fd2f6b4
1 changed files with 6 additions and 1 deletions
|
@ -21,6 +21,7 @@ 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 (options instanceof Array) {
|
if (options instanceof Array) {
|
||||||
|
@ -52,7 +53,11 @@ 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.whitelist.length || self.whitelist.indexOf(key) !== -1;
|
if(self.match) {
|
||||||
|
return key.match(self.match)
|
||||||
|
} else {
|
||||||
|
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]);
|
||||||
|
|
Loading…
Reference in a new issue