diff --git a/check.mjs b/check.mjs new file mode 100644 index 0000000000000000000000000000000000000000..93419eecfe177dc1eeb0a36b39be0b5a14ea6f88 --- /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 45b82045fc16ec5bd3c7f2bb06996006ac47b0e2..994e5b52a23e01557ca35ac20b8bdb8bbae25ca0 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",