Add latexmkrc in FileTypeManager

This commit is contained in:
Nate Stemen 2018-05-07 17:25:29 -04:00
parent 41654eb281
commit d108b11bc0
2 changed files with 17 additions and 10 deletions

View file

@ -3,7 +3,7 @@ Path = require("path")
module.exports = FileTypeManager =
TEXT_EXTENSIONS : [
"tex", "latex", "sty", "cls", "bst", "bib", "bibtex", "txt", "tikz", "rtex", "md", "asy"
"tex", "latex", "sty", "cls", "bst", "bib", "bibtex", "txt", "tikz", "rtex", "md", "asy", "latexmkrc"
]
IGNORE_EXTENSIONS : [
@ -34,7 +34,7 @@ module.exports = FileTypeManager =
extension = parts.slice(-1)[0]
if extension?
extension = extension.toLowerCase()
binaryFile = (@TEXT_EXTENSIONS.indexOf(extension) == -1 or parts.length <= 1)
binaryFile = (@TEXT_EXTENSIONS.indexOf(extension) == -1 or parts.length <= 1) and parts[0] != 'latexmkrc'
if binaryFile
return callback null, true
@ -52,13 +52,10 @@ module.exports = FileTypeManager =
if extension?
extension = extension.toLowerCase()
ignore = false
if name[0] == "."
if name[0] == "." and extension != 'latexmkrc'
ignore = true
if @IGNORE_EXTENSIONS.indexOf(extension) != -1
ignore = true
if @IGNORE_FILENAMES.indexOf(name) != -1
ignore = true
callback null, ignore

View file

@ -39,7 +39,7 @@ describe "FileTypeManager", ->
beforeEach ->
@stat = { size: 100 }
@fs.stat = sinon.stub().callsArgWith(1, null, @stat)
it "should return .tex files as not binary", ->
@FileTypeManager.isBinary "file.tex", "/path/on/disk", (error, binary) ->
binary.should.equal false
@ -80,10 +80,18 @@ describe "FileTypeManager", ->
@FileTypeManager.isBinary "tex", "/path/on/disk", (error, binary) ->
binary.should.equal true
it "should return .latexmkrc file as not binary", ->
@FileTypeManager.isBinary ".latexmkrc", "/path/on/disk", (error, binary) ->
binary.should.equal false
it "should return latexmkrc file as not binary", ->
@FileTypeManager.isBinary "latexmkrc", "/path/on/disk", (error, binary) ->
binary.should.equal false
it "should ignore the case of an extension", ->
@FileTypeManager.isBinary "file.TEX", "/path/on/disk", (error, binary) ->
binary.should.equal false
it "should return large text files as binary", ->
@stat.size = 2 * 1024 * 1024 # 2Mb
@FileTypeManager.isBinary "file.tex", "/path/on/disk", (error, binary) ->
@ -98,6 +106,10 @@ describe "FileTypeManager", ->
@FileTypeManager.shouldIgnore "path/.git", (error, ignore) ->
ignore.should.equal true
it "should not ignore .latexmkrc dotfile", ->
@FileTypeManager.shouldIgnore "path/.latexmkrc", (error, ignore) ->
ignore.should.equal false
it "should ignore __MACOSX", ->
@FileTypeManager.shouldIgnore "path/__MACOSX", (error, ignore) ->
ignore.should.equal true
@ -109,5 +121,3 @@ describe "FileTypeManager", ->
it "should ignore the case of the extension", ->
@FileTypeManager.shouldIgnore "file.AUX", (error, ignore) ->
ignore.should.equal true