Skip to content

Commit

Permalink
fix: node version check now uses process.versions.node (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
paperdave authored Aug 3, 2022
1 parent c0c6079 commit d07bcdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"text"
],
"lines": 99.5,
"branches": "98",
"branches": "97",
"statements": "99.5"
}
5 changes: 3 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import { readFileSync } from 'fs'
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
? Number(process.env.YARGS_MIN_NODE_VERSION)
: 12
if (process && process.version) {
const major = Number(process.version.match(/v([^.]+)/)![1])
const nodeVersion = process?.versions?.node ?? process?.version?.slice(1)
if (nodeVersion) {
const major = Number(nodeVersion.match(/^([^.]+)/)![1])
if (major < minNodeVersion) {
throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)
}
Expand Down

0 comments on commit d07bcdb

Please sign in to comment.