Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Survive ENOENTs (by ignoring new paths) #33

Merged
merged 2 commits into from

2 participants

@kmayer

Perhaps not the ideal solution, but at least the caller doesn't die.

#16 (also vojtajina/testacular#265)

There is also 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?).

@kmayer kmayer 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?).
e8eb6a5
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'
@paulmillr Owner

use and and isnt instead of && & == as it’s idiomatic coffee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@paulmillr
Owner

thanks. could you do the one change and we can merge?

@kmayer
@kmayer kmayer Use 'and' instead of '&&'
to be more coffee-like
b75779d
@paulmillr paulmillr merged commit 4a5aae4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
  1. @kmayer

    Survive ENOENTs (by ignoring new paths)

    kmayer authored
    #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?).
Commits on Dec 31, 2012
  1. @kmayer

    Use 'and' instead of '&&'

    kmayer authored
    to be more coffee-like
This page is out of date. Refresh to see the latest.
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 and 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'
Something went wrong with that request. Please try again.