Created
May 7, 2021 09:10
-
-
Save tvlgiao/b8d194535da5800d86eed5fb85b78d50 to your computer and use it in GitHub Desktop.
BigCommerce merge config.json
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
const fs = require('fs'); | |
const sourceConfig = require('./config-sunshine.json'); | |
const targetConfig = require('./config.json'); | |
const sourceVariation = sourceConfig.variations.filter(variation => variation.name == 'Yellow')[0]; | |
const targetVariation = targetConfig.variations.filter(variation => variation.name == 'Yellow')[0]; | |
Object.assign(targetVariation.settings, sourceVariation.settings); | |
Object.keys(targetVariation).forEach(name => { | |
if (!targetConfig.settings.hasOwnProperty(name)) { | |
targetVariation.settings = null; | |
delete targetVariation.settings[name]; | |
} | |
}); | |
fs.writeFileSync('./config.json', JSON.stringify(targetConfig, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment