From f9fe5efbb07e940bd2f53197f5d9a0f275ebe5d7 Mon Sep 17 00:00:00 2001 From: Kyle Filz Date: Wed, 7 May 2014 15:56:25 -0500 Subject: [PATCH] Fix running .cmd stubs through BufferedProcess ChildProcess.spawn only will run .exe files on Windows, not .cmd, .bat, .anythingElse. See joyent/node#2318 for more information. --- src/buffered-process.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/buffered-process.coffee b/src/buffered-process.coffee index c63f69180..537b117bb 100644 --- a/src/buffered-process.coffee +++ b/src/buffered-process.coffee @@ -39,7 +39,14 @@ class BufferedProcess # containing the exit status (optional). constructor: ({command, args, options, stdout, stderr, exit}={}) -> options ?= {} - @process = ChildProcess.spawn(command, args, options) + # Quick hack. Killing @process will only kill cmd.exe, and not the child + # process and will just orphan it. Does not escape ^ (cmd's escape symbol). + # Related to joyent/node#2318 + if process.platform is "win32" + @process = ChildProcess.spawn(process.env.comspec || "cmd.exe", + [ "/c", command ].concat(args), options) + else + @process = ChildProcess.spawn(command, args, options) @killed = false stdoutClosed = true