Skip to content

Commit

Permalink
Fix: Merge opt.ignored and our custom ignore function (fixes #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 16, 2018
1 parent f1fa55d commit 4fca711
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var anymatch = require('anymatch');
var defaultOpts = {
delay: 200,
events: ['add', 'change', 'unlink'],
ignored: [],
ignoreInitial: true,
queue: true,
};
Expand Down Expand Up @@ -85,7 +86,7 @@ function watch(glob, options, cb) {

var toWatch = positives.filter(exists);

opt.ignored = shouldBeIgnored;
opt.ignored = [].concat(opt.ignored, shouldBeIgnored);
var watcher = chokidar.watch(toWatch, opt);

function runComplete(err) {
Expand Down
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,25 @@ describe('glob-watcher', function() {

done();
});

it('passes ignores through to chokidar', function(done) {
var ignored = [singleAdd];
watcher = watch(outGlob, {
ignored: ignored,
});

watcher.once('change', function(filepath) {
// It should never reach here
expect(filepath).toNotExist();
done();
});

// We default `ignoreInitial` to true, so always wait for `on('ready')`
watcher.on('ready', changeFile);

// Just test the non-mutation in this test
expect(ignored.length).toEqual(1);

setTimeout(done, 1500);
});
});

0 comments on commit 4fca711

Please sign in to comment.