Merge pull request #63 from sharelatex/bg-fix-tikzmanager-exception

fix tikzmanager exception
This commit is contained in:
Brian Gough 2017-07-20 13:22:58 +01:00 committed by GitHub
commit 54852b216b
3 changed files with 10 additions and 2 deletions

View file

@ -22,8 +22,8 @@ module.exports = TikzManager =
_includesTikz: (resource) -> _includesTikz: (resource) ->
# check if we are using tikz externalize # check if we are using tikz externalize
content = resource.content.slice(0,65536) content = resource.content?.slice(0,65536)
if content.indexOf("\\tikzexternalize") >= 0 if content?.indexOf("\\tikzexternalize") >= 0
return true return true
else else
return false return false

View file

@ -18,6 +18,7 @@ describe "CompileManager", ->
"child_process": @child_process = {} "child_process": @child_process = {}
"./CommandRunner": @CommandRunner = {} "./CommandRunner": @CommandRunner = {}
"./DraftModeManager": @DraftModeManager = {} "./DraftModeManager": @DraftModeManager = {}
"./TikzManager": @TikzManager = {}
"fs": @fs = {} "fs": @fs = {}
@callback = sinon.stub() @callback = sinon.stub()
@ -55,6 +56,7 @@ describe "CompileManager", ->
@OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files) @OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files)
@OutputCacheManager.saveOutputFiles = sinon.stub().callsArgWith(2, null, @build_files) @OutputCacheManager.saveOutputFiles = sinon.stub().callsArgWith(2, null, @build_files)
@DraftModeManager.injectDraftMode = sinon.stub().callsArg(1) @DraftModeManager.injectDraftMode = sinon.stub().callsArg(1)
@TikzManager.needsOutputFile = sinon.stub().returns(false)
describe "normally", -> describe "normally", ->
beforeEach -> beforeEach ->

View file

@ -30,6 +30,12 @@ describe 'TikzManager', ->
{ path: 'output.tex' } { path: 'output.tex' }
]).should.equal false ]).should.equal false
it "should return false if the file has no content", ->
@TikzManager.needsOutputFile("main.tex", [
{ path: 'foo.tex' },
{ path: 'main.tex' }
]).should.equal false
describe "injectOutputFile", -> describe "injectOutputFile", ->
beforeEach -> beforeEach ->
@rootDir = "/mock" @rootDir = "/mock"