Don't delete knitr cache files

This commit is contained in:
James Allen
2016-09-22 14:14:29 +01:00
parent 79b3d2172b
commit f7b4883397
2 changed files with 8 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ module.exports = ResourceWriter =
do (file) -> do (file) ->
path = file.path path = file.path
should_delete = true should_delete = true
if path.match(/^output\./) or path.match(/\.aux$/) if path.match(/^output\./) or path.match(/\.aux$/) or path.match(/^cache\//) # knitr cache
should_delete = false should_delete = false
if path == "output.pdf" or path == "output.dvi" or path == "output.log" if path == "output.pdf" or path == "output.dvi" or path == "output.log"
should_delete = true should_delete = true

View File

@@ -55,6 +55,8 @@ describe "ResourceWriter", ->
}, { }, {
path: "extra.aux" path: "extra.aux"
type: "aux" type: "aux"
}, {
path: "cache/_chunk1"
}] }]
@resources = "mock-resources" @resources = "mock-resources"
@OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files) @OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files)
@@ -80,6 +82,11 @@ describe "ResourceWriter", ->
@ResourceWriter._deleteFileIfNotDirectory @ResourceWriter._deleteFileIfNotDirectory
.calledWith(path.join(@basePath, "extra.aux")) .calledWith(path.join(@basePath, "extra.aux"))
.should.equal false .should.equal false
it "should not delete the knitr cache file", ->
@ResourceWriter._deleteFileIfNotDirectory
.calledWith(path.join(@basePath, "cache/_chunk1"))
.should.equal false
it "should call the callback", -> it "should call the callback", ->
@callback.called.should.equal true @callback.called.should.equal true