You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ass/checkEngine.js

23 lines
865 B

const check = require("check-node-version");
const ENGINES = require('./package.json').engines;
const TLog = require('@tycrek/log');
const logger = new TLog();
function doCheck() {
return new Promise((resolve, reject) =>
check(ENGINES, (err, { isSatisfied: allSatisfied }) =>
err ? reject(err) : allSatisfied ? resolve('Node & npm version requirements satisfied!')
: reject(Object.entries(result.versions)
.filter(([, { isSatisfied }]) => (!isSatisfied))
.map(([packageName, { version: current, wanted: minimum }]) =>
`\nInvalid ${packageName} version!\n- Current: ${current}\n- Minimum: ${minimum}`)
.join('')
.concat('\nPlease update to continue!'))));
}
if (require.main !== module) module.exports = doCheck;
else doCheck()
.then((result) => logger.success(result))
.catch((err) => logger.error(err) && process.exit(1));