Boolean flags override even when not specified
See original GitHub issueWhen Yargs defaults are specified, they provide the value as flags to the command constructor. This means that when flags, command overrides, lerna json options and legacy options are merged, the flags will take precedence over any thing else because they have a value.
This can easily be reproduced by simply trying to use stream: true
in the lerna.json
. If you remove the option from, for example, RunCommand
it works. Similarly, if you rename it from boolean
to string
, it continues to work. So it seems that while _.defaults()
is doing the right thing (because false
is a value, where undefined
is not), providing a default that is considered a “value”, will break anything following the durable option convention.
Expected Behavior
Durable options should take precedence over Yargs defaults.
Current Behavior
Defaults override user-defined values not specified as flags.
Possible Solution
After digging a bit deeper, it seems that all we really have to do to get around this is to specify default: undefined
to any option that is a boolean
and doesn’t already have a default (because they default to false
. When _.defaults()
is called, they will then be overridden if they’re not specified by the user.
Steps to Reproduce
- Put
stream: true
in thelerna.json
- Run a command that should stream.
- It won’t stream.
Context
- References #893.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Wrote a test to confirm:
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.