Skip to content

Commit 4fca711

Browse files
committed
Fix: Merge opt.ignored and our custom ignore function (fixes #40)
1 parent f1fa55d commit 4fca711

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var anymatch = require('anymatch');
1010
var defaultOpts = {
1111
delay: 200,
1212
events: ['add', 'change', 'unlink'],
13+
ignored: [],
1314
ignoreInitial: true,
1415
queue: true,
1516
};
@@ -85,7 +86,7 @@ function watch(glob, options, cb) {
8586

8687
var toWatch = positives.filter(exists);
8788

88-
opt.ignored = shouldBeIgnored;
89+
opt.ignored = [].concat(opt.ignored, shouldBeIgnored);
8990
var watcher = chokidar.watch(toWatch, opt);
9091

9192
function runComplete(err) {

test/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,25 @@ describe('glob-watcher', function() {
319319

320320
done();
321321
});
322+
323+
it('passes ignores through to chokidar', function(done) {
324+
var ignored = [singleAdd];
325+
watcher = watch(outGlob, {
326+
ignored: ignored,
327+
});
328+
329+
watcher.once('change', function(filepath) {
330+
// It should never reach here
331+
expect(filepath).toNotExist();
332+
done();
333+
});
334+
335+
// We default `ignoreInitial` to true, so always wait for `on('ready')`
336+
watcher.on('ready', changeFile);
337+
338+
// Just test the non-mutation in this test
339+
expect(ignored.length).toEqual(1);
340+
341+
setTimeout(done, 1500);
342+
});
322343
});

0 commit comments

Comments
 (0)