Skip to content

Commit

Permalink
fix: clone arrays in merge utils
Browse files Browse the repository at this point in the history
  • Loading branch information
easingthemes committed Jan 31, 2024
1 parent 60eebbf commit 5c432f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/extendConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = (configPath, config) => {
}

// config merge
const extendedConfig = merge(config, override);
const copyConfig = merge({}, config);
const extendedConfig = merge(copyConfig, override);
return extendedConfig;
};
2 changes: 2 additions & 0 deletions utils/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = function merge(original = {}, newObject) {
&& !Array.isArray(newObject[prop])
&& !(newObject[prop] instanceof RegExp)) {
copy[prop] = merge(original[prop], newObject[prop]);
} else if (Array.isArray(newObject[prop])) {
copy[prop] = newObject[prop] ? [...newObject[prop]] : [...original[prop]];
} else {
copy[prop] = newObject[prop] || typeof newObject[prop] === 'boolean' ? newObject[prop] : original[prop];
}
Expand Down

0 comments on commit 5c432f8

Please sign in to comment.