overleaf/services/clsi/app/coffee/CommandRunner.coffee
2016-05-23 15:45:39 +01:00

17 lines
No EOL
749 B
CoffeeScript

spawn = require("child_process").spawn
logger = require "logger-sharelatex"
logger.info "using standard command runner"
module.exports = CommandRunner =
run: (project_id, command, directory, image, timeout, callback = (error) ->) ->
command = (arg.replace('$COMPILE_DIR', directory) for arg in command)
logger.log project_id: project_id, command: command, directory: directory, "running command"
logger.warn "timeouts and sandboxing are not enabled with CommandRunner"
proc = spawn command[0], command.slice(1), stdio: "inherit", cwd: directory
proc.on "error", (err)->
logger.err err:err, project_id:project_id, command: command, directory: directory, "error running command"
callback(err)
proc.on "close", () ->
callback()