scratch-desktop/scripts/rebuild-deps.js
Christopher Willis-Ford 6f7f6bb674 add script to merge scratch-gui deps
This is in preparation for having webpack build scratch-gui source
instead of consuming its build output. This script merges the
dependencies listed in package-deps.json with those listed in
scratch-gui's package.json, using the package-deps.json version in case
of conflict, then writes the result into the `devDependencies` section
of scratch-desktop's package.json.
2020-08-10 18:46:26 -07:00

26 lines
726 B
JavaScript

const fs = require('fs');
const desktopPackage = require('../package.json');
const desktopRawPackage = require('../package-deps.json');
const guiPackage = require('../node_modules/scratch-gui/package.json');
const sortObject = obj => Object
.keys(obj)
.sort()
.reduce(
(accumulator, currentKey) => {
accumulator[currentKey] = obj[currentKey];
return accumulator;
},
{}
);
desktopPackage.devDependencies = sortObject(Object.assign(
{},
guiPackage.devDependencies,
desktopRawPackage.devDependencies
));
let newDesktopPackage = JSON.stringify(desktopPackage, null, 2);
newDesktopPackage += '\n';
fs.writeFileSync('package.json', newDesktopPackage);