mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Don't return error if directory doesn't exist yet
This commit is contained in:
parent
42af7c4e63
commit
1313b06fb7
2 changed files with 26 additions and 16 deletions
|
@ -47,9 +47,8 @@ module.exports = OutputFileFinder =
|
||||||
proc.on "error", callback
|
proc.on "error", callback
|
||||||
proc.on "close", (code) ->
|
proc.on "close", (code) ->
|
||||||
if code != 0
|
if code != 0
|
||||||
error = new Error("find returned non-zero exit code: #{code}")
|
logger.warn {directory, code}, "find returned error, directory likely doesn't exist"
|
||||||
return callback(error)
|
return callback null, []
|
||||||
|
|
||||||
fileList = stdout.trim().split("\n")
|
fileList = stdout.trim().split("\n")
|
||||||
fileList = fileList.map (file) ->
|
fileList = fileList.map (file) ->
|
||||||
# Strip leading directory
|
# Strip leading directory
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe "OutputFileFinder", ->
|
||||||
@OutputFileFinder = SandboxedModule.require modulePath, requires:
|
@OutputFileFinder = SandboxedModule.require modulePath, requires:
|
||||||
"fs": @fs = {}
|
"fs": @fs = {}
|
||||||
"child_process": spawn: @spawn = sinon.stub()
|
"child_process": spawn: @spawn = sinon.stub()
|
||||||
"logger-sharelatex": { log: sinon.stub() }
|
"logger-sharelatex": { log: sinon.stub(), warn: sinon.stub() }
|
||||||
@directory = "/test/dir"
|
@directory = "/test/dir"
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ describe "OutputFileFinder", ->
|
||||||
@directory = "/base/dir"
|
@directory = "/base/dir"
|
||||||
@OutputFileFinder._getAllFiles @directory, @callback
|
@OutputFileFinder._getAllFiles @directory, @callback
|
||||||
|
|
||||||
|
describe "successfully", ->
|
||||||
|
beforeEach ->
|
||||||
@proc.stdout.emit(
|
@proc.stdout.emit(
|
||||||
"data",
|
"data",
|
||||||
["/base/dir/main.tex", "/base/dir/chapters/chapter1.tex"].join("\n") + "\n"
|
["/base/dir/main.tex", "/base/dir/chapters/chapter1.tex"].join("\n") + "\n"
|
||||||
|
@ -55,3 +57,12 @@ describe "OutputFileFinder", ->
|
||||||
["main.tex", "chapters/chapter1.tex"]
|
["main.tex", "chapters/chapter1.tex"]
|
||||||
).should.equal true
|
).should.equal true
|
||||||
|
|
||||||
|
describe "when the directory doesn't exist", ->
|
||||||
|
beforeEach ->
|
||||||
|
@proc.emit "close", 1
|
||||||
|
|
||||||
|
it "should call the callback with a blank array", ->
|
||||||
|
@callback.calledWith(
|
||||||
|
null,
|
||||||
|
[]
|
||||||
|
).should.equal true
|
||||||
|
|
Loading…
Reference in a new issue