From 3ce32096f2f51847c3f48418c6cf276b01134ccd Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Wed, 3 Apr 2024 09:35:05 +0530 Subject: [PATCH] Early Exit if Node Version is Lower (#870) --- index.ts | 2 +- tswatch.ts | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/index.ts b/index.ts index 782cb38..fefc970 100644 --- a/index.ts +++ b/index.ts @@ -155,7 +155,7 @@ app.get('/', (req, res) => { }); app.listen(port, host, () => { - console.log(`Testing plugins web listening on http://localhost:${port}`); + console.log(`Server listening at http://localhost:${port}`); }); //Dayjs localization diff --git a/tswatch.ts b/tswatch.ts index 41d7400..9dfa00e 100644 --- a/tswatch.ts +++ b/tswatch.ts @@ -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 -- \` to change it -`); + console.log( + `No port specified; defaulting to 3000. Change it with 'npm start -- '.`, + ); + port = 3000; } watch.start('--onSuccess', `node ./.js/index.js ${port}`); - -try { -} catch (e) { - watch.kill(); // Fatal error, kill the compiler instance. -}