@enplug/scripts
Version:
Enplug scripts
32 lines (26 loc) • 969 B
JavaScript
/**
* The script in FIX mode (--fix) updates versions in the packages.json file to those found in package-lock.json file
* to CHECK if have never versions installed and locked add to your scripts
* "check-packages": "check-packages"
* to CHECK and FIX add:
* "check-packages": "check-packages --fix"
* and run `npm run check-packages`
*
**/
;
const commandLineArgs = require('command-line-args');
const path = require('path');
const rootPath = process.cwd();
const checkAndUpdatePackagesVersions = require('./functions/checkAndUpdatePackagesVersions');
const optionDefinitions = [
{ name: 'fix', alias: 'f', type: Boolean },
];
const options = commandLineArgs(optionDefinitions);
try {
const pkg = require(path.join(rootPath, 'package.json'));
const lockPkg = require(path.join(rootPath, 'package-lock.json'));
checkAndUpdatePackagesVersions(pkg, lockPkg, options);
} catch (error) {
console.error(error);
}