-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clone startObj to prevent unintended mutation
FIXES #36
- Loading branch information
Showing
4 changed files
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* https://github.com/joshswan/gulp-merge/blob/master/LICENSE | ||
*/ | ||
|
||
const cloneDeep = require('lodash.clonedeep'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joshswan
Author
Owner
|
||
const mergeWith = require('lodash.mergewith'); | ||
const JSON5 = require('json5'); | ||
const path = require('path'); | ||
|
@@ -61,7 +62,7 @@ module.exports = function mergeJson(opts) { | |
throw new PluginError(PLUGIN_NAME, `${PLUGIN_NAME}: Invalid start and/or end object!`); | ||
} | ||
|
||
let merged = options.startObj; | ||
let merged = cloneDeep(options.startObj); | ||
let firstFile = null; | ||
|
||
function parseAndMerge(file) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Consider using
structuredClone
instead which is probably faster (supported at node 17+).