Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Survive ENOENTs (by ignoring new paths)

#16 (also vojtajina/testacular#265)

There is a pending test (since I too am not sure what to do) regarding what happens when the item finally appears (is it a file or directory?).
  • Loading branch information...
commit e8eb6a5631d6a7a2be99bbd65e3e2dfcd9e16ea0 1 parent 53d071c
@kmayer kmayer authored
Showing with 24 additions and 0 deletions.
  1. +1 −0  src/index.coffee
  2. +23 −0 test/chokidar-test.coffee
View
1  src/index.coffee
@@ -176,6 +176,7 @@ exports.FSWatcher = class FSWatcher extends EventEmitter
# Get the canonicalized absolute pathname.
fs.realpath item, (error, path) =>
+ return if error && error.code == 'ENOENT'
return @emit 'error', error if error?
# Get file info, check is it file, directory or something else.
fs.stat item, (error, stats) =>
View
23 test/chokidar-test.coffee
@@ -33,6 +33,8 @@ describe 'chokidar', ->
try fs.unlinkSync (getFixturePath 'add.txt'), 'b'
fs.writeFileSync (getFixturePath 'change.txt'), 'b'
fs.writeFileSync (getFixturePath 'unlink.txt'), 'b'
+ try fs.unlinkSync (getFixturePath 'subdir/add.txt'), 'b'
+ try fs.rmdirSync (getFixturePath 'subdir'), 'b'
after ->
try fs.unlinkSync (getFixturePath 'add.txt'), 'a'
@@ -90,6 +92,27 @@ describe 'chokidar', ->
spy.should.have.been.calledWith testPath
done()
+ it 'should survive ENOENT for missing subdirectories', ->
+ testDir = getFixturePath 'subdir'
+
+ @watcher.add testDir
+
+ xit 'should notice when a file appears in a new directory', (done) ->
+ spy = sinon.spy()
+ testDir = getFixturePath 'subdir'
+ testPath = getFixturePath 'subdir/add.txt'
+
+ @watcher.on 'add', spy
+ @watcher.add testDir
+
+ delay =>
+ spy.should.not.have.been.callled
+ fs.mkdirSync testDir, 0o755
+ fs.writeFileSync testPath, 'hello'
+ spy.should.have.been.calledOnce
+ spy.should.have.been.calledWith testPath
+ done()
+
describe 'is-binary', ->
it 'should be a function', ->
isBinary.should.be.a 'function'
Please sign in to comment.
Something went wrong with that request. Please try again.