Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-01 20:58:55 +0400
committerisaacs <i@izs.me>2012-03-01 20:58:55 +0400
commitabbda96de7725f89c497e727518c1e7c4dc26eeb (patch)
tree128d42695a2f4b3802d0d138e9a7b80c13df4a15
parent4bb4e9d0ca3c57e765561c6bb8a38b1b62dc0adf (diff)
Throw on undefined envs in config settings
-rw-r--r--lib/utils/ini.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/utils/ini.js b/lib/utils/ini.js
index 48d4f99ed..b033b6a04 100644
--- a/lib/utils/ini.js
+++ b/lib/utils/ini.js
@@ -323,8 +323,14 @@ function envReplace (f) {
if (typeof f !== "string" || !f) return f
// replace any ${ENV} values with the appropriate environ.
- return f.replace(/\$\{([^}]+)\}/g, function (orig, name, i, s) {
- return process.env[name] || orig
+ var envExpr = /(\\*)\$\{([^}]+)\}/g
+ return f.replace(envExpr, function (orig, esc, name, i, s) {
+ esc = esc.length && esc.length % 2
+ if (esc) return orig
+ if (undefined === process.env[name]) {
+ throw new Error("Failed to replace env in config: "+orig)
+ }
+ return process.env[name]
})
}