insomnia/scripts/check-version.js
Yash Shah 27184c4f2d
fixes #2552:addded a (slightly) more verbose output in check-version.js (#2559)
* fixes #2552:
* updated version script to show more verbose errors in case of a mismatch node version

* added suggested changes
* No output is printed if the node version is aaccurate
* changed colours for the messages to make them more prominent
2020-08-27 03:01:29 +12:00

31 lines
978 B
JavaScript

const fs = require('fs');
const GREEN_FG = '\x1b[32m';
const RED_FG = '\x1b[31m';
const YELLOW_FG = '\x1b[33m';
const UNDERSCORE = '\x1b[4m';
const BRIGHT = '\x1b[1m';
const RESET = '\x1b[0m';
const foundNodeVersion = process.versions.node;
const expectedNodeVersion = fs
.readFileSync('.nvmrc')
.toString()
.trim();
if (foundNodeVersion !== expectedNodeVersion) {
console.log(`${BRIGHT}${RED_FG}Incorrect node version installed ...${RESET}\n`);
console.log(`Current node version -> ${RED_FG}${foundNodeVersion}${RESET}`);
console.log(`Expected node version -> ${GREEN_FG}${expectedNodeVersion}${RESET}`);
console.log();
console.log(
`One solution to manage multiple versions of node is nvm, visit ${UNDERSCORE}https://github.com/nvm-sh/nvm${RESET}`,
);
console.log();
console.log(
`${BRIGHT}${YELLOW_FG}Remember to 'npm run clean && npm run bootstrap' after installing the expected version.${RESET}`,
);
console.log();
process.exit(1);
}