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

fix: choose correct config directory when require.main does not exist #1056

Merged
merged 6 commits into from Jan 31, 2018

Conversation

evocateur
Copy link
Contributor

So, it turns out Jest overrides the module-local require and neglects to assign require.main.filename (jestjs/jest#2150). Maybe I'll even get around to fixing it here, but in the meantime, we can work around it by avoiding the "extra" path.dirname() when it isn't neccessary (because require-main-filename defaults to process.cwd()).

Also, I changed a bunch of function parameters to avoid shadowing path, it was extremely confusing (and ridiculous to have an inner require('path').dirname when const path = require('path') is already present at the top of the file).

@evocateur
Copy link
Contributor Author

This fixes the (untested) fix from #1036, which exposed jest's nefarious activity.

@evocateur evocateur requested a review from bcoe January 24, 2018 00:28
@evocateur evocateur changed the title fix: choost correct config directory when require.main does not exist fix: choose correct config directory when require.main does not exist Jan 24, 2018
- Verifies that find-up can deal with non-directory startDir
- Removes process.chdir() in integration test helper in favor of opts.cwd
@evocateur evocateur merged commit a04678c into yargs:master Jan 31, 2018
@evocateur evocateur deleted the fix-require-main-missing branch January 31, 2018 19:43
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

Successfully merging this pull request may close these issues.

None yet

1 participant