-
-
Notifications
You must be signed in to change notification settings - Fork 248
Incorrect ENOENT error on Windows with shell=true when child exits with code 1 #446
Copy link
Copy link
Closed
Description
Summary
On Windows, when the execa child process exits with exit code 1 and the shell option is set to true, the error thrown is always ENOENT even though the child process was found and executed correctly (albeit with a non-zero exit code).
Using this code as an example:
const execa = require("execa");
execa('node -e "process.exit(1)"', { shell: true })
.catch(e => console.log(`Exit 1: ${e}\n`));Expected behavior
The output should be:
Exit 1: Error: Command failed with exit code 1: node -e "process.exit(1)"
Actual behavior
The current output is:
Exit 1: Error: Command failed with ENOENT: node -e "process.exit(1)"
spawn node -e "process.exit(1)" ENOENT
Additional information
The issue appears to be related to verifyENOENT from the cross-spawn library and its incorrect detection of whether a valid file was found to execute.
The following code shows that the issue only occurs when the child's exit code is 1, but not for exit code 2:
const execa = require("execa");
execa('node -e "process.exit(2)"', { shell: true })
.catch(e => console.log(`Exit 2: ${e}\n`));
execa('node -e "process.exit(1)"', { shell: true })
.catch(e => console.log(`Exit 1: ${e}\n`));As an additional test case, I'd recommend the following code because exit is a shell command, not an executable in the path. This code should not throw an ENOENT error.
const execa = require("execa");
execa('exit 1', { shell: true })
.catch(e => console.log(`Exit 1: ${e}\n`));Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels