Răsfoiți Sursa

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

fix tikzmanager exception
Brian Gough 9 ani în urmă
părinte
comite
54852b216b

+ 2 - 2
services/clsi/app/coffee/TikzManager.coffee

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

+ 2 - 0
services/clsi/test/unit/coffee/CompileManagerTests.coffee

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

+ 6 - 0
services/clsi/test/unit/coffee/TikzManager.coffee

@@ -30,6 +30,12 @@ describe 'TikzManager', ->
 				{ path: 'output.tex' }
 			]).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", ->
 		beforeEach ->
 			@rootDir = "/mock"