Skip to content

Commit

Permalink
fix(cli): added node version check
Browse files Browse the repository at this point in the history
Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Aug 24, 2023
1 parent 4b55394 commit ffea25f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"workspaces": [
"packages/*",
"other-packages/*",
"website"
"website",
"examples/*"
],
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion packages/saber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"markdown-it-footnote": "3.0.2"
},
"engines": {
"node": ">=16"
"node": ">=16 <17"
},
"volta": {
"node": "16.20.2"
Expand Down
12 changes: 12 additions & 0 deletions packages/saber/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import { cac } from 'cac'
import { log } from 'saber-log'
import commands from './cli-commands'

function isSupported() {
const [major] = process.versions.node.split('.', 1).map(Number)
return major >= 16 && major < 17
}

if (!isSupported()) {
log.error(
`Saber requires Node.js >= 16 and < 17 to work currently, your current Node.js version is ${process.versions.node}.`
)
process.exit(1)
}

const cli = cac()
commands(cli)

Expand Down

0 comments on commit ffea25f

Please sign in to comment.