-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2020 from bigcommerce/integrity_hash
CHECKOUT-8519: Load scripts with integrity hashes to meet PCI4 requirements
- Loading branch information
Showing
6 changed files
with
150 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { existsSync, readFileSync, writeFileSync } = require('fs'); | ||
const { isArray, mergeWith } = require('lodash'); | ||
|
||
function mergeManifests(outputPath, sourcePathA, sourcePathB) { | ||
if (!existsSync(sourcePathA) || !existsSync(sourcePathB)) { | ||
throw new Error('Unable to merge manifests as one of the sources does not exist'); | ||
} | ||
|
||
const manifestA = JSON.parse(readFileSync(sourcePathA, 'utf8')); | ||
const manifestB = JSON.parse(readFileSync(sourcePathB, 'utf8')); | ||
|
||
const result = mergeWith(manifestA, manifestB, (valueA, valueB) => { | ||
if (!isArray(valueA) || !isArray(valueB)) { | ||
return undefined; | ||
} | ||
|
||
return valueA.concat(valueB); | ||
}); | ||
|
||
writeFileSync(outputPath, JSON.stringify(result, null, 2), 'utf8'); | ||
} | ||
|
||
module.exports = mergeManifests; |
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