|
|
|
@ -31,6 +31,7 @@ var child_process = require('child_process'),
|
|
|
|
|
utils = require('./utils'), |
|
|
|
|
quote = require('shell-quote'), |
|
|
|
|
_ = require('underscore-node'), |
|
|
|
|
treeKill = require('tree-kill'), |
|
|
|
|
logger = require('./logger').logger; |
|
|
|
|
|
|
|
|
|
function Compile(compiler, env) { |
|
|
|
@ -265,12 +266,17 @@ Compile.prototype.exec = function (command, args, options) {
|
|
|
|
|
env: env, |
|
|
|
|
detached: process.platform == 'linux' |
|
|
|
|
}); |
|
|
|
|
var running = true; |
|
|
|
|
function kill() { |
|
|
|
|
if (running) treeKill(child.pid); |
|
|
|
|
} |
|
|
|
|
var stderr = ""; |
|
|
|
|
var stdout = ""; |
|
|
|
|
var timeout; |
|
|
|
|
if (timeoutMs) timeout = setTimeout(function () { |
|
|
|
|
logger.warn("Timeout for", command, args, "after", timeoutMs, "ms"); |
|
|
|
|
okToCache = false; |
|
|
|
|
child.kill(); |
|
|
|
|
kill(); |
|
|
|
|
stderr += "\nKilled - processing time exceeded"; |
|
|
|
|
}, timeoutMs); |
|
|
|
|
var truncated = false; |
|
|
|
@ -279,7 +285,7 @@ Compile.prototype.exec = function (command, args, options) {
|
|
|
|
|
if (stdout.length > maxOutput) { |
|
|
|
|
stdout += "\n[Truncated]"; |
|
|
|
|
truncated = true; |
|
|
|
|
child.kill(); |
|
|
|
|
kill(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
stdout += data; |
|
|
|
@ -289,7 +295,7 @@ Compile.prototype.exec = function (command, args, options) {
|
|
|
|
|
if (stderr.length > maxOutput) { |
|
|
|
|
stderr += "\n[Truncated]"; |
|
|
|
|
truncated = true; |
|
|
|
|
child.kill(); |
|
|
|
|
kill(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
stderr += data; |
|
|
|
@ -297,6 +303,7 @@ Compile.prototype.exec = function (command, args, options) {
|
|
|
|
|
child.on('exit', function (code) { |
|
|
|
|
logger.debug({type: 'exited', code: code}); |
|
|
|
|
if (timeout !== undefined) clearTimeout(timeout); |
|
|
|
|
running = false; |
|
|
|
|
}); |
|
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
|
child.on('error', function (e) { |
|
|
|
|