diff --git a/lib/config.js b/lib/config.js index cacecb92c..708907edd 100644 --- a/lib/config.js +++ b/lib/config.js @@ -123,7 +123,7 @@ var normalizeConfig = function(config) { var readConfigFile = function(filepath) { - var configEnv = { + var initSandbox = { // constants LOG_DISABLE: constant.LOG_DISABLE, LOG_ERROR: constant.LOG_ERROR, @@ -137,7 +137,7 @@ var readConfigFile = function(filepath) { __filename: filepath, __dirname: path.dirname(filepath) }; - + var configEnv = vm.createContext(initSandbox); // TODO(vojta): remove var CONST_ERR = '%s is not supported anymore.\n\tPlease use `frameworks = ["%s"];` instead.'; @@ -169,7 +169,7 @@ var readConfigFile = function(filepath) { configSrc = coffee.compile(configSrc.toString(), {bare: true}); } - vm.runInNewContext(configSrc, configEnv); + vm.runInContext(configSrc, configEnv); } catch(e) { if (e.name === 'SyntaxError') { log.error('Syntax error in config file!\n' + e.message); @@ -181,6 +181,11 @@ var readConfigFile = function(filepath) { process.exit(1); } + + // Clean up the env before we return it. + for (var i in initSandbox) { + delete configEnv[i]; + } return configEnv; }; @@ -228,11 +233,12 @@ var parseConfig = function(configFilePath, cliOptions) { }; // merge the config from config file and cliOptions (precendense) + Object.getOwnPropertyNames(configFromFile).forEach(function(key) { + config[key] = configFromFile[key]; + }); Object.getOwnPropertyNames(config).forEach(function(key) { if (cliOptions.hasOwnProperty(key)) { config[key] = cliOptions[key]; - } else if (configFromFile.hasOwnProperty(key)) { - config[key] = configFromFile[key]; } });