Early Exit if Node Version is Lower (#870)

This commit is contained in:
Rajarshee Chatterjee
2024-04-03 09:35:05 +05:30
committed by GitHub
parent 39523ac032
commit 3ce32096f2
2 changed files with 16 additions and 9 deletions
+15 -8
View File
@@ -1,18 +1,25 @@
import { TscWatchClient } from 'tsc-watch/client';
const nodeVersion = Number(process.versions.node.split('.')[0]);
if (nodeVersion < 18) {
console.error(
`\nYou are using Node.js ${process.versions.node}. For lnreader-plugins, Node.js version >= v18.0.0 is required.`,
);
process.exit(1);
}
const watch = new TscWatchClient();
let port = Number(process.argv[2]);
if (!port) {
console.log(`Port not specified! Setting default 3000!
Run \`npm start -- <port>\` to change it
`);
console.log(
`No port specified; defaulting to 3000. Change it with 'npm start -- <PORT>'.`,
);
port = 3000;
}
watch.start('--onSuccess', `node ./.js/index.js ${port}`);
try {
} catch (e) {
watch.kill(); // Fatal error, kill the compiler instance.
}