Closed shadowspawn closed 1 year ago
Merging #6 (b62a195) into main (3124ed3) will not change coverage. The diff coverage is
100.00%
.
:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
@@ Coverage Diff @@
## main #6 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 1 1
Lines 161 161
Branches 71 71
=======================================
Hits 159 159
Misses 2 2
Impacted Files | Coverage Δ | |
---|---|---|
index.js | 98.75% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
For historical interest, this was reported as an issue on the original Minimist repo by @poppinlp:
Seems parse error for this case https://web.archive.org/web/20200904203628/https://github.com/substack/minimist/issues/154/
I've run the code like node index.js -a="aaa=bbb" --a2="aaa=bbb"
And here are the output for process.argv
, minimist parsed result and yargs-parser parsed result:
origin argv [
'blabla/.nvm/versions/node/v14.7.0/bin/node',
'blabla not important',
'-a=aaa=bbb',
'--a2=aaa=bbb'
]
minimist { _: [], a: 'aaa', a2: 'aaa=bbb' }
yargs parser { _: [], a: 'aaa=bbb', a2: 'aaa=bbb' }
You could see, for -a
, minimist seems to get the wrong result.
Problem
A short option with an embedded
=
later in the argument is parsed inconsistently and with data loss.In particular:
-a=b=c
gives same result as-a=b
(lost trailing=c
)-ab=c
gives same result as-a=c
(lost leadingb
)Fixes #5
Solution
Make code more explicit and test for
=
at start when looking for possible value.-a=b=c
makes optiona
have valueb=c
.-ab=c
makes optiona
true and optionb
have valuec
.(In my first commit I made
-ab=c
give optionb
the value=c
by only treating the=
as special at the start. I checked Yargs and found it set value toc
. I can see a rationale for the parsing to treat it like an expansion, so-ab=c
=>-a
-b=c
, and optionb
has valuec
. More comfortable matching Yargs with this behaviour.)