Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not load configuration from package.json under test runners #783

Closed
kevinoid opened this issue Feb 15, 2017 · 1 comment
Closed

Does not load configuration from package.json under test runners #783

kevinoid opened this issue Feb 15, 2017 · 1 comment

Comments

@kevinoid
Copy link

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.

I have created an example of the issue as a gist.

Thanks,
Kevin

kevinoid added a commit to kevinoid/node-project-template that referenced this issue Feb 15, 2017
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>
@kevinoid
Copy link
Author

kevinoid commented Sep 9, 2020

This is no longer an issue since v15.0.0 removed package.json-based parserConfiguration in #1460.

@kevinoid kevinoid closed this as completed Sep 9, 2020
kevinoid added a commit to kevinoid/node-project-template that referenced this issue Sep 9, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant