Skip to content

Work around yargs/yargs-parser bug that misparses similar arg names when unknown-options-as-args is enabled #171

@Xunnamius

Description

@Xunnamius
The problem

I have observed that yargs/yargs-parser will incorrectly parse (i.e. conflate, drop, or do something strange with) unknown flags that resemble known flags when unknown-options-as-args is enabled. For example: --skip-package/--skip (known) and --skip-task/--skip-tasks (unknown), when provided in the same argv, will lead to strange behavior.

Black flag should be able to work around this. Needs more investigation to rule out a BF/BFE bug. Behavior shows up in vanilla yargs too.

If it is a Yargs bug and we work around it, this needs to be added to https://github.com/Xunnamius/black-flag/blob/main/docs/bf-vs-yargs.md#irrelevant-differences yargs-parser needs the fix instead. Temporary fix is available: npm install --save-dev yargs-parser@npm:@-xun/yargs-parser-experimental. Relevant issue: yargs/yargs-parser#501

Reproduction steps

See @-xun/symbiote's project topology command.

Various failing permutations:

 symbiote project topology --run release --options --skip-task 7
 symbiote project topology --run release --env NODE_NO_WARNINGS=1 --options '\--skip-task 7'
 symbiote project topology --run release --env NODE_NO_WARNINGS=1 --options --skip-task 7
 symbiote project topology --run release --env NODE_NO_WARNINGS=1 --options --skip-tasks 7
 symbiote project topology --run release --options --skip-tasks 7 --env NODE_NO_WARNINGS=1
 symbiote project topology --run release --options '--skip-tasks' --env NODE_NO_WARNINGS=1
 symbiote project topology --run release --skip none --env NODE_NO_WARNINGS=1 --options --skip-task 7
 symbiote project topology --run release --skip-package none --env NODE_NO_WARNINGS=1 --options --skip 7

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions