mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
27184c4f2d
* 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
31 lines
978 B
JavaScript
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);
|
|
}
|