Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
spawn: map exit code 127 to ENOENT for node@0.8
Browse files Browse the repository at this point in the history
Node.js v0.8 will not emit a separate `error` event if the command
could not be found. Exit code 127 is reserved for “command not found”,
see http://tldp.org/LDP/abs/html/exitcodes.html.
  • Loading branch information
sonicdoe authored and othiym23 committed Apr 8, 2015
1 parent 269a623 commit 26d36e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/utils/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ function spawn (cmd, args, options) {
er.file = cmd
cooked.emit("error", er)
}).on("close", function (code, signal) {
cooked.emit("close", code, signal)
// Create ENOENT error because Node.js v0.8 will not emit
// an `error` event if the command could not be found.
if (code === 127) {
var er = new Error('spawn ENOENT')
er.code = 'ENOENT'
er.errno = 'ENOENT'
er.syscall = 'spawn'
er.file = cmd
cooked.emit('error', er)
} else {
cooked.emit("close", code, signal)
}
})

cooked.stdin = raw.stdin
Expand Down

0 comments on commit 26d36e9

Please sign in to comment.