From 73348f1f3b4da848c3ec416799c119ba3cc0f9f6 Mon Sep 17 00:00:00 2001 From: Dave Caruso Date: Wed, 13 Jul 2022 19:09:09 -0400 Subject: [PATCH 1/4] fix: node version uses process.versions.node closes #447 --- lib/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 8c413229..f852cb1d 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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 && (process.versions ? 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`) } From c49d28029f5b239e4c1826859d13560a6c3ba841 Mon Sep 17 00:00:00 2001 From: Dave Caruso Date: Mon, 18 Jul 2022 20:30:01 -0400 Subject: [PATCH 2/4] style: use optional chaining for version check --- lib/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index f852cb1d..21cb6afe 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -19,7 +19,7 @@ import { readFileSync } from 'fs' const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION) ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12 -const nodeVersion = process && (process.versions ? process.versions.node : process.version.slice(1)) +const nodeVersion = process?.versions?.node || process?.version?.slice(1) if (nodeVersion) { const major = Number(nodeVersion.match(/^([^.]+)/)![1]) if (major < minNodeVersion) { From e1dc9873de54b32bd696c2392e76546bdc7b3540 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 19 Jul 2022 12:06:33 -0400 Subject: [PATCH 3/4] Update lib/index.ts --- lib/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index 21cb6afe..3cc34257 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -19,7 +19,7 @@ import { readFileSync } from 'fs' const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION) ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12 -const nodeVersion = process?.versions?.node || process?.version?.slice(1) +const nodeVersion = process?.versions?.node ?? process?.version?.slice(1) if (nodeVersion) { const major = Number(nodeVersion.match(/^([^.]+)/)![1]) if (major < minNodeVersion) { From 2de1c063b7681bbe21bfd576ef0c5127ef8a6eb7 Mon Sep 17 00:00:00 2001 From: Dave Caruso Date: Tue, 19 Jul 2022 16:29:20 -0400 Subject: [PATCH 4/4] chore: lower nyc branch threshold as per @bcoe --- .nycrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nycrc b/.nycrc index 3b315160..04de9940 100644 --- a/.nycrc +++ b/.nycrc @@ -8,6 +8,6 @@ "text" ], "lines": 99.5, - "branches": "98", + "branches": "97", "statements": "99.5" }