Created
June 5, 2019 06:10
-
-
Save KMR-zoar/2be0174418d6a9c429eafc771daf5462 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 master = process.argv[2] | |
const source = process.argv[3] | |
const fs = require('fs') | |
if (master === undefined || source === undefined) { | |
console.log('Insufficient arguments.') | |
process.exit(1) | |
} | |
const masterObj = JSON.parse(fs.readFileSync(master, { encoding: 'utf8' })) | |
const sourceObj = JSON.parse(fs.readFileSync(source, { encoding: 'utf8' })) | |
const increasedKeyArray = {} | |
const decreasedKeyArray = {} | |
Object.keys(masterObj).forEach(key => { | |
if (!(sourceObj[key] === undefined)) { | |
masterObj[key] = sourceObj[key] | |
} else { | |
increasedKeyArray[key] = masterObj[key] | |
} | |
}) | |
Object.keys(sourceObj).forEach(key => { | |
if (masterObj[key] === undefined) { | |
decreasedKeyArray[key] = sourceObj[key] | |
} | |
}) | |
fs.writeFileSync('result.json', JSON.stringify(masterObj, null, 2)) | |
fs.writeFileSync( | |
'increasedKeys.json', | |
JSON.stringify(increasedKeyArray, null, 2) | |
) | |
fs.writeFileSync( | |
'decreasedKeys.json', | |
JSON.stringify(decreasedKeyArray, null, 2) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment