diff options
author | Jakob Krigovsky <jakob.krigovsky@gmail.com> | 2015-04-04 11:44:27 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-04-08 22:31:11 +0300 |
commit | 26d36e9cf0eca69fe1863d2ea536c28555b9e8de (patch) | |
tree | c923d9f1cc78ee870193cb6de171b9ead21fc754 /lib | |
parent | 269a62327bbe114583f3666c61fcbe81d17a1e57 (diff) |
spawn: map exit code 127 to ENOENT for node@0.8
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/spawn.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/utils/spawn.js b/lib/utils/spawn.js index 953671857..74684521f 100644 --- a/lib/utils/spawn.js +++ b/lib/utils/spawn.js @@ -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 |