misty-config
Advanced tools
Comparing version 1.0.0 to 1.0.1
29
index.js
@@ -7,12 +7,27 @@ var util = require('util'), | ||
config.util.substituteEnv = function (config) { | ||
var decoratedEnvironment = | ||
_.object(_(process.env).map(function (v, k) { | ||
return [util.format("${%s}", k), v]; | ||
})); | ||
config.util.substituteDeep(decoratedEnvironment, config); | ||
var substituteEnv = function (config) { | ||
function _recur(obj) { | ||
_(obj).forEach(function (v, k) { | ||
if (_.isString(v)) { | ||
var match = v.match('^[$]{(.*)}$'); | ||
if (match) { | ||
if (! process.env[match[1]]) { | ||
throw new Error(util.format('misty-config: %s not set in the environment', v)); | ||
} else { | ||
obj[k] = process.env[match[1]]; | ||
} | ||
} | ||
} else if (_.isObject(v) || _.isArray(v)) { | ||
_recur(v); | ||
} | ||
}); | ||
} | ||
_recur(config); | ||
}; | ||
config.util.substituteEnv(config); | ||
substituteEnv(config); | ||
config.util.makeImmutable(config); | ||
module.exports = config; |
{ | ||
"name": "misty-config", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Cascading configuration with environment variable support", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
56
5512
5
2