Skip to content

Commit

Permalink
fix(watcher): ignore fs.stat errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Connor committed Jul 1, 2013
1 parent e9a53bd commit 74ccc9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/file-list.js
Expand Up @@ -186,17 +186,22 @@ var List = function(patterns, excludes, emitter, preprocess) {
pending++;
matchedAndNotIgnored++;
fs.stat(path, function(error, stat) {
if (!stat.isDirectory()) {
// TODO(vojta): reuse file objects
var file = new File(path, stat.mtime);

preprocess(file, function() {
buckets[i].push(file);
finish();
});
} else {
log.debug('Ignored directory "%s"', path);
if (error) {
log.debug('An error occured while reading "%s"', path);
finish();
} else {
if (!stat.isDirectory()) {
// TODO(vojta): reuse file objects
var file = new File(path, stat.mtime);

preprocess(file, function() {
buckets[i].push(file);
finish();
});
} else {
log.debug('Ignored directory "%s"', path);
finish();
}
}
});
});
Expand Down
9 changes: 9 additions & 0 deletions test/unit/file-list.spec.coffee
Expand Up @@ -144,6 +144,15 @@ describe 'file-list', ->
expect(files.served).to.exist
done()

it 'should handle fs.stat errors', (done) ->
sinon.stub(mockFs, 'stat').yields([new Error(), null])
list = new m.List patterns('/some/*.js'), [], emitter, preprocessMock

refreshListAndThen (files) ->
mockFs.stat.restore()
done()



#============================================================================
# List.reload()
Expand Down

0 comments on commit 74ccc9a

Please sign in to comment.