File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ const pathKey = require('path-key')();
77function resolveCommandAttempt ( parsed , withoutPathExt ) {
88 const cwd = process . cwd ( ) ;
99 const hasCustomCwd = parsed . options . cwd != null ;
10+ // Worker threads do not have process.chdir()
11+ const shouldSwitchCwd = hasCustomCwd && process . chdir !== undefined ;
1012
1113 // If a custom `cwd` was specified, we need to change the process cwd
1214 // because `which` will do stat calls but does not support a custom cwd
13- if ( hasCustomCwd ) {
15+ if ( shouldSwitchCwd ) {
1416 try {
1517 process . chdir ( parsed . options . cwd ) ;
1618 } catch ( err ) {
@@ -28,7 +30,9 @@ function resolveCommandAttempt(parsed, withoutPathExt) {
2830 } catch ( e ) {
2931 /* Empty */
3032 } finally {
31- process . chdir ( cwd ) ;
33+ if ( shouldSwitchCwd ) {
34+ process . chdir ( cwd ) ;
35+ }
3236 }
3337
3438 // If we successfully resolved, ensure that an absolute path is returned
You can’t perform that action at this time.
0 commit comments