You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the use of require-main-filename in pkgUp, searching for package.json differs between test runners (which use the test runner's package.json) and scripts (which use their own module's package.json). This causes the yargs configuration to be loaded from different files based on how scripts are invoked, which makes it difficult to test a script's command-line parsing behavior.
Pretend that the file calling Yargs is the one that was invoked, even if
it was not. This way the Yargs configuration will always be loaded from
package.json.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid
added a commit
to kevinoid/node-project-template
that referenced
this issue
Feb 18, 2019
Unfortunately yargs configuration in package.json takes precedence over
.parserConfiguration(), so under mocha (which has yargs in its
package.json) the .parserConfiguration() call is ignored. Re-add the
require.main workaround to prevent this.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This hasn't been an issue since yargs@15.0.0 dropped support for
package.json-based parserConfiguration.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Due to the use of
require-main-filename
inpkgUp
, searching forpackage.json
differs between test runners (which use the test runner'spackage.json
) and scripts (which use their own module'spackage.json
). This causes the yargs configuration to be loaded from different files based on how scripts are invoked, which makes it difficult to test a script's command-line parsing behavior.I have created an example of the issue as a gist.
Thanks,
Kevin
The text was updated successfully, but these errors were encountered: