Skip to content

Commit

Permalink
detect node version
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
  • Loading branch information
PPpro committed Aug 10, 2023
1 parent 584c32d commit e9b79a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"module": "index.js",
"scripts": {
"server": "http-server . -p 8002 -o playground/index.html",
"preinstall": "node ./scripts/detect-npm-version.js",
"postinstall": "gulp build-debug-infos && npm run build-declaration && npm run bundle-adapter && npm run fetch-ral && npm run install:typedoc-plugin && npm run install:native-pack-tool",
"build": "gulp build",
"build:dev": "gulp build-h5-source",
Expand Down
10 changes: 10 additions & 0 deletions scripts/detect-npm-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { spawnSync } = require('child_process');
const chalk = require('chalk');

const p = spawnSync('npm', ['-v']);
const currentVersion = p.stdout.toString().replace('\n', '');
const version = Number.parseInt(currentVersion.split('.')[0]);
if (version < 7) {
console.error(chalk.red(`The current npm version is ${currentVersion}, please upgrade to at least 7.0.0.\nThe suggested node version is 18.17.0.\n`));
process.exit(1);
}

0 comments on commit e9b79a0

Please sign in to comment.