[LocalCommandRunner] run: block a double call of the callback

The subprocess event handler fires the "error" and "close" event in case
 of a failure.
Both events would call the given callback, resulting in double
 processing of the subprocess result downstream.

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
This commit is contained in:
Jakob Ackermann 2019-09-19 00:44:02 +02:00 committed by Jakob Ackermann
parent c700a0ab9d
commit cf8533bee1

View file

@ -15,6 +15,7 @@
*/
let CommandRunner
const { spawn } = require('child_process')
const _ = require('underscore')
const logger = require('logger-sharelatex')
logger.info('using standard command runner')
@ -24,6 +25,8 @@ module.exports = CommandRunner = {
let key, value
if (callback == null) {
callback = function(error) {}
} else {
callback = _.once(callback)
}
command = Array.from(command).map(arg =>
arg.toString().replace('$COMPILE_DIR', directory)