fix: do not use cwd when resolving package.json for yargs parsing config #726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug introduced with #556, demonstrated by https://github.com/laggingreflex/yargs-test-720.
Also, while investigating changes from 556, I found that validation logic for the
.implies()
method interprets a prefix of--no-
on a key as a tiny DSL for "when this key is not given". From this, we can actually ignore theboolean-negation: false
setting for the.implies()
method becauseboolean-negation
affects parsing but not the DSL of implications. To demonstrate this, I added some tests (with comments) showing how the DSL is interpreted.The following use-cases are supported for
.implies()
:bar: 'foo'
= use of--bar
requires that--foo
be givenbar: '--no-foo'
= use of--bar
requires that--foo
cannot be givenbar: 'noFoo'
= use of--bar
requires that--noFoo
(or--no-foo
with"boolean-negation": false
) be givenbar: '--no-noFoo'
= use of--bar
requires that--noFoo
(or--no-foo
with"boolean-negation": false
) cannot be givenIn all use-cases, the
boolean-negation
config setting only changes how--no-foo
(or--no-ANYTHING
) is parsed inargv
, it does not change how the implications are interpreted.Thus, I also reverted 556 in its entirety.
Note that this fixes the bug found by #720, but it technically doesn't close 720 because I have not attempted to change the API to allow parsing config to be defined in any other way besides a
"yargs"
stanza in package.json.