mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow optional image name to be passed
This commit is contained in:
parent
9b6999085a
commit
d924da0d2d
6 changed files with 14 additions and 6 deletions
|
@ -2,7 +2,7 @@ spawn = require("child_process").spawn
|
||||||
logger = require "logger-sharelatex"
|
logger = require "logger-sharelatex"
|
||||||
|
|
||||||
module.exports = CommandRunner =
|
module.exports = CommandRunner =
|
||||||
run: (project_id, command, directory, timeout, callback = (error) ->) ->
|
run: (project_id, command, directory, image, timeout, callback = (error) ->) ->
|
||||||
command = (arg.replace('$COMPILE_DIR', directory) for arg in command)
|
command = (arg.replace('$COMPILE_DIR', directory) for arg in command)
|
||||||
logger.log project_id: project_id, command: command, directory: directory, "running command"
|
logger.log project_id: project_id, command: command, directory: directory, "running command"
|
||||||
logger.warn "timeouts and sandboxing are not enabled with CommandRunner"
|
logger.warn "timeouts and sandboxing are not enabled with CommandRunner"
|
||||||
|
|
|
@ -28,6 +28,7 @@ module.exports = CompileManager =
|
||||||
mainFile: request.rootResourcePath
|
mainFile: request.rootResourcePath
|
||||||
compiler: request.compiler
|
compiler: request.compiler
|
||||||
timeout: request.timeout
|
timeout: request.timeout
|
||||||
|
image: request.imageName
|
||||||
}, (error) ->
|
}, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
logger.log project_id: request.project_id, time_taken: Date.now() - timer.start, "done compile"
|
logger.log project_id: request.project_id, time_taken: Date.now() - timer.start, "done compile"
|
||||||
|
|
|
@ -6,7 +6,7 @@ CommandRunner = require(Settings.clsi?.commandRunner or "./CommandRunner")
|
||||||
|
|
||||||
module.exports = LatexRunner =
|
module.exports = LatexRunner =
|
||||||
runLatex: (project_id, options, callback = (error) ->) ->
|
runLatex: (project_id, options, callback = (error) ->) ->
|
||||||
{directory, mainFile, compiler, timeout} = options
|
{directory, mainFile, compiler, timeout, image} = options
|
||||||
compiler ||= "pdflatex"
|
compiler ||= "pdflatex"
|
||||||
timeout ||= 60000 # milliseconds
|
timeout ||= 60000 # milliseconds
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ module.exports = LatexRunner =
|
||||||
else
|
else
|
||||||
return callback new Error("unknown compiler: #{compiler}")
|
return callback new Error("unknown compiler: #{compiler}")
|
||||||
|
|
||||||
CommandRunner.run project_id, command, directory, timeout, callback
|
CommandRunner.run project_id, command, directory, image, timeout, callback
|
||||||
|
|
||||||
_latexmkBaseCommand: [ "latexmk", "-cd", "-f", "-jobname=output", "-auxdir=$COMPILE_DIR", "-outdir=$COMPILE_DIR"]
|
_latexmkBaseCommand: [ "latexmk", "-cd", "-f", "-jobname=output", "-auxdir=$COMPILE_DIR", "-outdir=$COMPILE_DIR"]
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ module.exports = RequestParser =
|
||||||
compile.options.timeout
|
compile.options.timeout
|
||||||
default: RequestParser.MAX_TIMEOUT
|
default: RequestParser.MAX_TIMEOUT
|
||||||
type: "number"
|
type: "number"
|
||||||
|
response.imageName = @_parseAttribute "imageName",
|
||||||
|
compile.options.imageName,
|
||||||
|
type: "string"
|
||||||
|
|
||||||
if response.timeout > RequestParser.MAX_TIMEOUT
|
if response.timeout > RequestParser.MAX_TIMEOUT
|
||||||
response.timeout = RequestParser.MAX_TIMEOUT
|
response.timeout = RequestParser.MAX_TIMEOUT
|
||||||
|
@ -71,7 +74,6 @@ module.exports = RequestParser =
|
||||||
throw "#{name} attribute should be a #{options.type}"
|
throw "#{name} attribute should be a #{options.type}"
|
||||||
else
|
else
|
||||||
return options.default if options.default?
|
return options.default if options.default?
|
||||||
throw "Default not implemented"
|
|
||||||
return attribute
|
return attribute
|
||||||
|
|
||||||
_sanitizePath: (path) ->
|
_sanitizePath: (path) ->
|
||||||
|
|
|
@ -44,6 +44,7 @@ describe "CompileManager", ->
|
||||||
project_id: @project_id = "project-id-123"
|
project_id: @project_id = "project-id-123"
|
||||||
compiler: @compiler = "pdflatex"
|
compiler: @compiler = "pdflatex"
|
||||||
timeout: @timeout = 42000
|
timeout: @timeout = 42000
|
||||||
|
imageName: @image = "example.com/image"
|
||||||
@Settings.compileDir = "compiles"
|
@Settings.compileDir = "compiles"
|
||||||
@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}"
|
@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}"
|
||||||
@ResourceWriter.syncResourcesToDisk = sinon.stub().callsArg(3)
|
@ResourceWriter.syncResourcesToDisk = sinon.stub().callsArg(3)
|
||||||
|
@ -64,6 +65,7 @@ describe "CompileManager", ->
|
||||||
mainFile: @rootResourcePath
|
mainFile: @rootResourcePath
|
||||||
compiler: @compiler
|
compiler: @compiler
|
||||||
timeout: @timeout
|
timeout: @timeout
|
||||||
|
image: @image
|
||||||
})
|
})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,13 @@ describe "LatexRunner", ->
|
||||||
@directory = "/local/compile/directory"
|
@directory = "/local/compile/directory"
|
||||||
@mainFile = "main-file.tex"
|
@mainFile = "main-file.tex"
|
||||||
@compiler = "pdflatex"
|
@compiler = "pdflatex"
|
||||||
|
@image = "example.com/image"
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
@project_id = "project-id-123"
|
@project_id = "project-id-123"
|
||||||
|
|
||||||
describe "runLatex", ->
|
describe "runLatex", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@CommandRunner.run = sinon.stub().callsArg(4)
|
@CommandRunner.run = sinon.stub().callsArg(5)
|
||||||
|
|
||||||
describe "normally", ->
|
describe "normally", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -33,11 +34,12 @@ describe "LatexRunner", ->
|
||||||
mainFile: @mainFile
|
mainFile: @mainFile
|
||||||
compiler: @compiler
|
compiler: @compiler
|
||||||
timeout: @timeout = 42000
|
timeout: @timeout = 42000
|
||||||
|
image: @image
|
||||||
@callback
|
@callback
|
||||||
|
|
||||||
it "should run the latex command", ->
|
it "should run the latex command", ->
|
||||||
@CommandRunner.run
|
@CommandRunner.run
|
||||||
.calledWith(@project_id, sinon.match.any, @directory, @timeout)
|
.calledWith(@project_id, sinon.match.any, @directory, @image, @timeout)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
describe "with an .Rtex main file", ->
|
describe "with an .Rtex main file", ->
|
||||||
|
@ -46,6 +48,7 @@ describe "LatexRunner", ->
|
||||||
directory: @directory
|
directory: @directory
|
||||||
mainFile: "main-file.Rtex"
|
mainFile: "main-file.Rtex"
|
||||||
compiler: @compiler
|
compiler: @compiler
|
||||||
|
image: @image
|
||||||
timeout: @timeout = 42000
|
timeout: @timeout = 42000
|
||||||
@callback
|
@callback
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue