From 86c5208cebabed6a14c4ddbb9c1b7929747005e5 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Tue, 5 Nov 2024 12:39:52 +0300 Subject: [PATCH] check node version --- check.mjs | 23 +++++++++++++++++++++++ package.json | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 check.mjs diff --git a/check.mjs b/check.mjs new file mode 100644 index 000000000..93419eecf --- /dev/null +++ b/check.mjs @@ -0,0 +1,23 @@ +import { execSync } from "node:child_process" +import chalk from "chalk" + +const NODE_VERSION = 18 + +function nodeVersion() { + const str = execSync(`node --version`, {encoding: "utf-8"}).trim() + const result = str.match(/(\d+).(\d+).(\d+)/); + + return { + major: result[1], + minor: result[2], + patch: result[3] + } +} + +function main() { + if (nodeVersion().major < NODE_VERSION) { + console.log(chalk.red.bold(`Warning: You are using an outdated version of node: ${nodeVersion().major}. Current version: ${NODE_VERSION}`)) + } +} + +main() \ No newline at end of file diff --git a/package.json b/package.json index 45b82045f..994e5b52a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "//": "DO NOT ADD dependencies or devDependencies clauses to this level! Keep subfolders autonomous.", "scripts": { - "prepare": "cd incremental && npm i && cd .. && cd interop && npm i && cd .. && cd arkoala && npm i && cd .. && cd arkoala-arkts && npm i", + "prepare": "node check.mjs && cd incremental && npm i && cd .. && cd interop && npm i && cd .. && cd arkoala && npm i && cd .. && cd arkoala-arkts && npm i", "ohos-sdk": "npm run ohos-sdk --prefix arkoala/arkui-common", "ets:plugin:compile": "npm run compile --prefix arkoala/ets-plugin", "compiler:plugin:compile": "npm run compile --prefix incremental/compiler-plugin", -- Gitee