From 40b80005db614bedbbdd38e6f788fdc7ecebdfe5 Mon Sep 17 00:00:00 2001 From: bcoe Date: Thu, 4 Jun 2020 09:04:52 -0700 Subject: [PATCH 1/4] build!: drops Node 6. moves to Node 10 as supported version --- .github/workflows/ci.yaml | 2 +- README.md | 6 ++++++ package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 82416464..0213d80f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [8, 10, 12, 13] + node: [10, 12, 14] steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 diff --git a/README.md b/README.md index bae61c2a..73a99c3c 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,12 @@ node example.js --unknown-option --known-option 2 --string-option --unknown-opti { _: ['--unknown-option'], knownOption: 2, stringOption: '--unknown-option2' } ``` +## Supported Node.js Versions + +Libraries in this ecosystem make a best effort to track +[Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a +post on why we thin this is valuable](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). + ## Special Thanks The yargs project evolves from optimist and minimist. It owes its diff --git a/package.json b/package.json index 7bf3236a..1acaabc0 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,6 @@ "index.js" ], "engines": { - "node": ">=6" + "node": ">=10" } } From 57c5c4c4d69d4553864e47492bea95a836e77743 Mon Sep 17 00:00:00 2001 From: bcoe Date: Thu, 4 Jun 2020 09:07:56 -0700 Subject: [PATCH 2/4] chore: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a99c3c..48a32cb4 100644 --- a/README.md +++ b/README.md @@ -443,7 +443,7 @@ node example.js --unknown-option --known-option 2 --string-option --unknown-opti Libraries in this ecosystem make a best effort to track [Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a -post on why we thin this is valuable](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). +post on why we think this is valuable](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). ## Special Thanks From e5d07554af6ce83535fcde3a6e42f54839b452d3 Mon Sep 17 00:00:00 2001 From: bcoe Date: Thu, 4 Jun 2020 09:08:53 -0700 Subject: [PATCH 3/4] chore: nit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48a32cb4..eff195c3 100644 --- a/README.md +++ b/README.md @@ -443,7 +443,7 @@ node example.js --unknown-option --known-option 2 --string-option --unknown-opti Libraries in this ecosystem make a best effort to track [Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a -post on why we think this is valuable](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). +post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). ## Special Thanks From 0f35103df839ac46e090d5df2d5a3477323cce05 Mon Sep 17 00:00:00 2001 From: bcoe Date: Sat, 6 Jun 2020 09:58:22 -0700 Subject: [PATCH 4/4] chore: throw on unsupported versions --- index.js | 13 ++++++++++++- test/yargs-parser.js | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c14c1fc7..24962d66 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,17 @@ const path = require('path') const tokenizeArgString = require('./lib/tokenize-arg-string') const util = require('util') +// See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our +// version support policy. The YARGS_MIN_NODE_VERSION is used for testing only. +const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION) + ? Number(process.env.YARGS_MIN_NODE_VERSION) : 10 +if (process && process.version) { + const major = Number(process.version.match(/v([^.]+)/)[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`) + } +} + function parse (args, opts) { opts = Object.assign(Object.create(null), opts) // allow a string argument to be passed in rather @@ -626,8 +637,8 @@ function parse (args, opts) { } function applyEnvVars (argv, configOnly) { + if (!process) return if (typeof envPrefix === 'undefined') return - const prefix = typeof envPrefix === 'string' ? envPrefix : '' Object.keys(process.env).forEach(function (envVar) { if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) { diff --git a/test/yargs-parser.js b/test/yargs-parser.js index f5cbc183..e017a08b 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -3823,4 +3823,13 @@ describe('yargs-parser', function () { } }) }) + + it('throws error for unsupported Node.js versions', () => { + process.env.YARGS_MIN_NODE_VERSION = '55' + delete require.cache[require.resolve('../')] + expect(() => { + require('../') + }).to.throw(/yargs parser supports a minimum Node.js version of 55/) + delete process.env.YARGS_MIN_NODE_VERSION + }) })