Skip to content

Instantly share code, notes, and snippets.

@cliffano
Created October 14, 2021 04:24
Show Gist options
  • Save cliffano/811993ffbe52890c272fa8279b6fd0d8 to your computer and use it in GitHub Desktop.
Save cliffano/811993ffbe52890c272fa8279b6fd0d8 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var parser = require('fast-xml-parser');
const file1 = process.argv[2]
const file2 = process.argv[3]
console.log("Comparing " + file1 + " to " + file2)
const xmlData1 = fs.readFileSync(file1, { encoding: 'utf-8' })
const xmlData2 = fs.readFileSync(file2, { encoding: 'utf-8' })
const json1 = parser.parse(xmlData1);
const json2 = parser.parse(xmlData2);
let map1 = {};
let map2 = {};
json1.crx.response.data.packages.package.forEach(function (package) {
map1[package.name] = package
});
json2.crx.response.data.packages.package.forEach(function (package) {
map2[package.name] = package
});
console.log("Iterating map1");
Object.keys(map1).forEach(function (item) {
if (Object.keys(map2).indexOf(item) == -1) {
console.log("2 doesn't have " + map1[item].name + "-" + map1[item].version);
} else if (map1[item].version != map2[item].version) {
console.log("both have but diff vers: " + map1[item].name + "-" + map1[item].version + " ___ " + map2[item].name + "-" + map2[item].version);
}
});
console.log("Iterating map2");
Object.keys(map2).forEach(function (item) {
if (Object.keys(map1).indexOf(item) == -1) {
console.log("1 doesn't have " + map2[item].name + "-" + map2[item].version);
} else if (map1[item].version != map2[item].version) {
console.log("both have but diff vers: " + map1[item].name + "-" + map1[item].version + " ___ " + map2[item].name + "-" + map2[item].version);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment