From 1b970b6c445659a731967550ec6132c582613bea Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Wed, 23 Nov 2016 11:09:30 -0600 Subject: [PATCH] Use _.clone() instead of _.cloneDeep() for config overrides. This prevents configs used in lifting Sails programmatically from getting messed up -- for instance an instantiated Redis client passed directly into `sails.config.sockets.adapterOptions.pubClient`. --- lib/app/configuration/load.js | 4 ++-- lib/app/load.js | 2 +- lib/hooks/userconfig/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/app/configuration/load.js b/lib/app/configuration/load.js index 0553ec609..76e4b726a 100644 --- a/lib/app/configuration/load.js +++ b/lib/app/configuration/load.js @@ -46,7 +46,7 @@ module.exports = function(sails) { mapOverrides: function(cb) { // Clone the `overrides` that were passed in. - var overrides = _.cloneDeep(sails.config || {}); + var overrides = _.clone(sails.config || {}); // TODO: bring the rconf stuff from bin/sails-lift in here @@ -139,7 +139,7 @@ module.exports = function(sails) { var implicitDefaults = self.defaults(overrides.appPath || process.cwd()); // Extend copy of implicit defaults with user config - var mergedConfig = _.merge(_.cloneDeep(implicitDefaults), overrides); + var mergedConfig = _.merge(_.clone(implicitDefaults), overrides); cb(null, mergedConfig); } diff --git a/lib/app/load.js b/lib/app/load.js index 5576d3fc6..527490eaf 100644 --- a/lib/app/load.js +++ b/lib/app/load.js @@ -31,7 +31,7 @@ module.exports = function(sails) { // Ensure override is an object and clone it (or make an empty object if it's not) configOverride = configOverride || {}; - sails.config = _.cloneDeep(configOverride); + sails.config = _.clone(configOverride); // If host is explicitly specified, set `explicitHost` diff --git a/lib/hooks/userconfig/index.js b/lib/hooks/userconfig/index.js index b97c29dcd..8ec7033f7 100644 --- a/lib/hooks/userconfig/index.js +++ b/lib/hooks/userconfig/index.js @@ -28,7 +28,7 @@ module.exports = function(sails) { sails.log.verbose('Loading app config...'); // Grab reference to mapped overrides - var overrides = _.cloneDeep(sails.config); + var overrides = _.clone(sails.config); // If appPath not specified yet, use process.cwd()