Skip to content

Conversation

@ltk
Copy link

@ltk ltk commented Aug 2, 2016

Resolves #936

A variable process.cwd() was problematic for the invocation of resolveCwd on https://github.com/avajs/ava/compare/master...ltk:ltk/fix-936?expand=1#diff-2d5bbda346ebb54b9745d10f2fb5b1b6R37 when using the CLI from outside of the package.json directory.

This PR normalizes the cwd to the pkgDir for every invocation.

this.options.require = (this.options.require || []).map(function (moduleId) {
var originalCwd = process.cwd();
if (options.pkgDir) {
process.chdir(options.pkgDir);
Copy link
Member

@sindresorhus sindresorhus Aug 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using process.chdir is almost always a bad idea. It changes the CWD globally and can cause race issues and all kinds of problems. See: #985 (comment)

@sindresorhus
Copy link
Member

@novemberborn would be the best one to review this.

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ltk will you have a chance to change the code to use resolve-from rather than chdir?

@ltk
Copy link
Author

ltk commented Sep 20, 2016

Yeah, I'll update this later today. Thanks for the suggestion!

@sindresorhus
Copy link
Member

@ltk Friendly ping :)

@sindresorhus sindresorhus force-pushed the master branch 2 times, most recently from 4bc021e to 476c653 Compare October 18, 2016 03:23
@sindresorhus
Copy link
Member

Closing for lack of response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants