From 31cee0af913c2ced98d1a38f742c3dfb8baddbcc Mon Sep 17 00:00:00 2001 From: Krishna Acondy Date: Mon, 13 Sep 2021 08:41:58 +0100 Subject: [PATCH] chore(ci): add node version check --- .github/workflows/build.yml | 2 +- checkNodeVersion.js | 16 ++++++++++++++++ package.json | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 checkNodeVersion.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8960e9c..b0452a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - node-version: [12.x] + node-version: [14.17.5] steps: - uses: actions/checkout@v2 diff --git a/checkNodeVersion.js b/checkNodeVersion.js new file mode 100644 index 0000000..ac3d46d --- /dev/null +++ b/checkNodeVersion.js @@ -0,0 +1,16 @@ +const result = process.versions +if (result && result.node) { + if (parseInt(result.node) < 14) { + console.log( + '\x1b[31m%s\x1b[0m', + `❌ Process failed due to Node Version,\nPlease install and use Node Version >= 14\nYour current Node Version is: ${result.node}` + ) + process.exit(1) + } +} else { + console.log( + '\x1b[31m%s\x1b[0m', + 'Something went wrong while checking Node version' + ) + process.exit(1) +} diff --git a/package.json b/package.json index ddd7825..02c70e9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "scripts": { "test": "jest --coverage", "build": "rimraf build && tsc", + "preinstall": "node checkNodeVersion", + "prebuild": "node checkNodeVersion", "prepublishOnly": "cp -r ./build/* . && rm -rf ./build && rm -rf ./src && rm tsconfig.json", "postpublish": "git clean -fd", "package:lib": "npm run build && cp ./package.json build && cp README.md build && cd build && npm version \"5.0.0\" && npm pack",