CommandRunner.coffee 749 B

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