Skip to content

Commit d07bcdb

Browse files
authored
fix: node version check now uses process.versions.node (#450)
1 parent c0c6079 commit d07bcdb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.nycrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"text"
99
],
1010
"lines": 99.5,
11-
"branches": "98",
11+
"branches": "97",
1212
"statements": "99.5"
1313
}

lib/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import { readFileSync } from 'fs'
1919
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
2020
? Number(process.env.YARGS_MIN_NODE_VERSION)
2121
: 12
22-
if (process && process.version) {
23-
const major = Number(process.version.match(/v([^.]+)/)![1])
22+
const nodeVersion = process?.versions?.node ?? process?.version?.slice(1)
23+
if (nodeVersion) {
24+
const major = Number(nodeVersion.match(/^([^.]+)/)![1])
2425
if (major < minNodeVersion) {
2526
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`)
2627
}

0 commit comments

Comments
 (0)