From 2a9ccb743064b386d9c8d0507a09e66ae8c5868a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Jun 2022 10:32:27 -0400 Subject: [PATCH 01/10] chore(deps): update dependency mocha to v10 (#440) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89412fcf..9cff4753 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "eslint-plugin-import": "^2.20.1", "eslint-plugin-node": "^11.0.0", "gts": "^3.0.0", - "mocha": "^9.0.0", + "mocha": "^10.0.0", "puppeteer": "^13.4.0", "rimraf": "^3.0.2", "rollup": "^2.22.1", From a0305515248ed493b82b52489c28e554dc783a8e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 12:12:43 -0400 Subject: [PATCH 02/10] chore(deps): update dependency rollup-plugin-ts to v3 (#442) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cff4753..0ca06c40 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "rimraf": "^3.0.2", "rollup": "^2.22.1", "rollup-plugin-cleanup": "^3.1.1", - "rollup-plugin-ts": "^2.0.5", + "rollup-plugin-ts": "^3.0.0", "serve": "^13.0.0", "standardx": "^7.0.0", "start-server-and-test": "^1.11.2", From 4f1060b50759fadbac3315c5117b0c3d65b0a7d8 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Tue, 5 Jul 2022 17:16:58 +0100 Subject: [PATCH 03/10] fix: parse options ending with 3+ hyphens (#434) Before this commit, options ending with three or more hyphens were being parsed as positional arguments, because a regular expression didn't have a start anchor. Co-authored-by: Benjamin E. Coe --- lib/yargs-parser.ts | 2 +- test/yargs-parser.cjs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 571a0cbc..5f776705 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -225,7 +225,7 @@ export class YargsParser { if (arg !== '--' && isUnknownOptionAsArg(arg)) { pushPositional(arg) // ---, ---=, ----, etc, - } else if (truncatedArg.match(/---+(=|$)/)) { + } else if (truncatedArg.match(/^---+(=|$)/)) { // options without key name are invalid. pushPositional(arg) continue diff --git a/test/yargs-parser.cjs b/test/yargs-parser.cjs index aa6bf6bf..97add48c 100644 --- a/test/yargs-parser.cjs +++ b/test/yargs-parser.cjs @@ -3588,6 +3588,13 @@ describe('yargs-parser', function () { args.bar.should.equal('--goodnight moon') }) + // see: https://github.com/yargs/yargs-parser/issues/433 + it('handles strings with three or more trailing dashes', function () { + const args = parser('--foo "hello---" --bar="world---"') + args.foo.should.equal('hello---') + args.bar.should.equal('world---') + }) + it('respects inner quotes (string)', function () { const args = parser('cmd --foo ""Hello"" --bar ""World"" --baz="":)""') args.foo.should.equal('"Hello"') From a072f9ad541d3c70486282640df836315287ff9a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 13:41:49 -0400 Subject: [PATCH 04/10] chore(deps): update dependency puppeteer to v15 (#444) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ca06c40..c97b4594 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "eslint-plugin-node": "^11.0.0", "gts": "^3.0.0", "mocha": "^10.0.0", - "puppeteer": "^13.4.0", + "puppeteer": "^15.0.0", "rimraf": "^3.0.2", "rollup": "^2.22.1", "rollup-plugin-cleanup": "^3.1.1", From fd30238cecd4145bb67e12779b86ea477b5cdd11 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 14:35:40 -0400 Subject: [PATCH 05/10] chore(deps): update dependency serve to v14 (#449) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c97b4594..cdc700a2 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "rollup": "^2.22.1", "rollup-plugin-cleanup": "^3.1.1", "rollup-plugin-ts": "^3.0.0", - "serve": "^13.0.0", + "serve": "^14.0.0", "standardx": "^7.0.0", "start-server-and-test": "^1.11.2", "ts-transform-default-export": "^1.0.2", From c474bc10c3aa0ae864b95e5722730114ef15f573 Mon Sep 17 00:00:00 2001 From: Kyle Herock Date: Tue, 19 Jul 2022 12:03:30 -0400 Subject: [PATCH 06/10] fix(halt-at-non-option): prevent known args from being parsed when "unknown-options-as-args" is enabled (#438) --- lib/yargs-parser.ts | 2 +- test/yargs-parser.cjs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 5f776705..764ca64e 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -222,7 +222,7 @@ export class YargsParser { let value: string // any unknown option (except for end-of-options, "--") - if (arg !== '--' && isUnknownOptionAsArg(arg)) { + if (arg !== '--' && /^-/.test(arg) && isUnknownOptionAsArg(arg)) { pushPositional(arg) // ---, ---=, ----, etc, } else if (truncatedArg.match(/^---+(=|$)/)) { diff --git a/test/yargs-parser.cjs b/test/yargs-parser.cjs index 97add48c..492e3b90 100644 --- a/test/yargs-parser.cjs +++ b/test/yargs-parser.cjs @@ -3008,6 +3008,16 @@ describe('yargs-parser', function () { _: ['./file.js', '--foo', '--', 'barbar'] }) }) + + it('is not influenced by unknown options when "unknown-options-as-args" is true', function () { + const parse = parser( + ['-v', '--long', 'arg', './file.js', '--foo', '--', 'barbar'], + { configuration: { 'halt-at-non-option': true, 'unknown-options-as-args': true }, boolean: ['foo'] } + ) + parse.should.deep.equal({ + _: ['-v', '--long', 'arg', './file.js', '--foo', '--', 'barbar'] + }) + }) }) describe('unknown-options-as-args = true', function () { From a89259ff41d6f5312b3ce8a30bef343a993f395a Mon Sep 17 00:00:00 2001 From: Blake Bourque Date: Tue, 19 Jul 2022 12:21:21 -0400 Subject: [PATCH 07/10] feat: allow the browser build to be imported (#443) Adding this small change will allow cloudflare worker users to easily use the yargs-parser as a library. Co-authored-by: Benjamin E. Coe --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index cdc700a2..988e2ec0 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "require": "./build/index.cjs" }, "./build/index.cjs" + ], + "./browser": [ + "./browser.js" ] }, "type": "module", From c0c60792e5a907d759e6802f3e11c4a18b69cb14 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Aug 2022 14:58:58 -0400 Subject: [PATCH 08/10] chore(deps): update dependency puppeteer to v16 (#451) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 988e2ec0..ab4178bb 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint-plugin-node": "^11.0.0", "gts": "^3.0.0", "mocha": "^10.0.0", - "puppeteer": "^15.0.0", + "puppeteer": "^16.0.0", "rimraf": "^3.0.2", "rollup": "^2.22.1", "rollup-plugin-cleanup": "^3.1.1", From d07bcdbe43075f7201fbe8a08e491217247fe1f1 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 3 Aug 2022 15:05:44 -0400 Subject: [PATCH 09/10] fix: node version check now uses process.versions.node (#450) --- .nycrc | 2 +- lib/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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" } diff --git a/lib/index.ts b/lib/index.ts index 8c413229..3cc34257 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?.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 90067a0de2c08c8fd98298043eebd72ea91ca8cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Aug 2022 15:23:12 -0400 Subject: [PATCH 10/10] chore(main): release yargs-parser 21.1.0 (#446) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 456110db..ee3274ab 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{".":"21.0.1"} \ No newline at end of file +{".":"21.1.0"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ca50b82e..de2808cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [21.1.0](https://github.com/yargs/yargs-parser/compare/yargs-parser-v21.0.1...yargs-parser-v21.1.0) (2022-08-03) + + +### Features + +* allow the browser build to be imported ([#443](https://github.com/yargs/yargs-parser/issues/443)) ([a89259f](https://github.com/yargs/yargs-parser/commit/a89259ff41d6f5312b3ce8a30bef343a993f395a)) + + +### Bug Fixes + +* **halt-at-non-option:** prevent known args from being parsed when "unknown-options-as-args" is enabled ([#438](https://github.com/yargs/yargs-parser/issues/438)) ([c474bc1](https://github.com/yargs/yargs-parser/commit/c474bc10c3aa0ae864b95e5722730114ef15f573)) +* node version check now uses process.versions.node ([#450](https://github.com/yargs/yargs-parser/issues/450)) ([d07bcdb](https://github.com/yargs/yargs-parser/commit/d07bcdbe43075f7201fbe8a08e491217247fe1f1)) +* parse options ending with 3+ hyphens ([#434](https://github.com/yargs/yargs-parser/issues/434)) ([4f1060b](https://github.com/yargs/yargs-parser/commit/4f1060b50759fadbac3315c5117b0c3d65b0a7d8)) + ### [21.0.1](https://github.com/yargs/yargs-parser/compare/yargs-parser-v21.0.0...yargs-parser-v21.0.1) (2022-02-27) diff --git a/package.json b/package.json index ab4178bb..8910778b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yargs-parser", - "version": "21.0.1", + "version": "21.1.0", "description": "the mighty option parser used by yargs", "main": "build/index.cjs", "exports": {