|
|
@ -3,7 +3,6 @@
|
|
|
|
const path = require('path');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
const cproc = require('child_process');
|
|
|
|
const cproc = require('child_process');
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { paths, pluginNamePattern } = require('../constants');
|
|
|
|
const { paths, pluginNamePattern } = require('../constants');
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +17,23 @@ function sortDependencies(dependencies) {
|
|
|
|
}, {});
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function merge(to, from) {
|
|
|
|
|
|
|
|
// Poor man's version of _.merge()
|
|
|
|
|
|
|
|
if (Object.values(from).every(val => typeof val !== 'object')) {
|
|
|
|
|
|
|
|
return Object.assign(to, from);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(from).forEach((key) => {
|
|
|
|
|
|
|
|
if (Object.getPrototypeOf(from[key]) === Object.prototype) {
|
|
|
|
|
|
|
|
to[key] = merge(to[key], from[key]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
to[key] = from[key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return to;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pkgInstall.updatePackageFile = () => {
|
|
|
|
pkgInstall.updatePackageFile = () => {
|
|
|
|
let oldPackageContents = {};
|
|
|
|
let oldPackageContents = {};
|
|
|
|
|
|
|
|
|
|
|
@ -43,7 +59,7 @@ pkgInstall.updatePackageFile = () => {
|
|
|
|
// Sort dependencies alphabetically
|
|
|
|
// Sort dependencies alphabetically
|
|
|
|
dependencies = sortDependencies({ ...dependencies, ...defaultPackageContents.dependencies });
|
|
|
|
dependencies = sortDependencies({ ...dependencies, ...defaultPackageContents.dependencies });
|
|
|
|
|
|
|
|
|
|
|
|
const packageContents = { ..._.merge(oldPackageContents, defaultPackageContents), dependencies, devDependencies };
|
|
|
|
const packageContents = { ...merge(oldPackageContents, defaultPackageContents), dependencies, devDependencies };
|
|
|
|
fs.writeFileSync(paths.currentPackage, JSON.stringify(packageContents, null, 2));
|
|
|
|
fs.writeFileSync(paths.currentPackage, JSON.stringify(packageContents, null, 2));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|