Skip to content

Commit

Permalink
Use _.clone() instead of _.cloneDeep() for config overrides.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
sgress454 committed Nov 28, 2016
1 parent 8c4e578 commit 1b970b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/app/configuration/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/app/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/userconfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1b970b6

Please sign in to comment.