From d18832641a2fddaeba52d8c9a2593f29bcd448e4 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Wed, 19 Aug 2015 18:02:40 +0300 Subject: [PATCH] Fixed issue where if local.js exists then grunt test will run on that environment config and possibly delete collections We only extend the config object with the local.js custom/local environment if we are on production or development environment. If test environment is used we don't merge it with local.js to avoid running test suites on a prod/dev environment (which delete records and make modifications) --- config/config.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/config.js b/config/config.js index 82070cf82e..df8abd6d20 100644 --- a/config/config.js +++ b/config/config.js @@ -159,9 +159,14 @@ var initGlobalConfig = function () { var environmentConfig = require(path.join(process.cwd(), 'config/env/', process.env.NODE_ENV)) || {}; // Merge config files - var envConf = _.merge(defaultConfig, environmentConfig); + var config = _.merge(defaultConfig, environmentConfig); - var config = _.merge(envConf, (fs.existsSync(path.join(process.cwd(), 'config/env/local.js')) && require(path.join(process.cwd(), 'config/env/local.js'))) || {}); + // We only extend the config object with the local.js custom/local environment if we are on + // production or development environment. If test environment is used we don't merge it with local.js + // to avoid running test suites on a prod/dev environment (which delete records and make modifications) + if (process.env.NODE_ENV !== 'test') { + config = _.merge(config, (fs.existsSync(path.join(process.cwd(), 'config/env/local.js')) && require(path.join(process.cwd(), 'config/env/local.js'))) || {}); + } // Initialize global globbed files initGlobalConfigFiles(config, assets);