Skip to content

Instantly share code, notes, and snippets.

@tvlgiao
Created May 7, 2021 09:10
Show Gist options
  • Save tvlgiao/b8d194535da5800d86eed5fb85b78d50 to your computer and use it in GitHub Desktop.
Save tvlgiao/b8d194535da5800d86eed5fb85b78d50 to your computer and use it in GitHub Desktop.
BigCommerce merge config.json
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