added regexp filtering to nconf env store

This commit is contained in:
joaoafrmartins 2014-01-10 00:17:52 +00:00
parent 022b9bc507
commit 681fd2f6b4

View file

@ -21,6 +21,7 @@ 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 (options instanceof Array) {
@ -52,7 +53,11 @@ Env.prototype.loadEnv = function () {
this.readOnly = false;
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) {
if (self.separator) {
self.set(common.key.apply(common, key.split(self.separator)), process.env[key]);