From abbda96de7725f89c497e727518c1e7c4dc26eeb Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 1 Mar 2012 08:58:55 -0800 Subject: Throw on undefined envs in config settings --- lib/utils/ini.js | 10 ++++++++-- 1 file 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] }) } -- cgit v1.2.3