diff --git a/lib/watchpack.js b/lib/watchpack.js index ddc9138..1a7b331 100644 --- a/lib/watchpack.js +++ b/lib/watchpack.js @@ -31,6 +31,9 @@ const stringToRegexp = ignored => { const ignoredToFunction = ignored => { if (Array.isArray(ignored)) { + if (ignored.length === 0) { + return () => false; + } const regexp = new RegExp(ignored.map(i => stringToRegexp(i)).join("|")); return x => regexp.test(x.replace(/\\/g, "/")); } else if (typeof ignored === "string") { diff --git a/test/Watchpack.js b/test/Watchpack.js index 4559c62..f791df5 100644 --- a/test/Watchpack.js +++ b/test/Watchpack.js @@ -269,6 +269,28 @@ describe("Watchpack", function() { }); }); + it("should watch a file in a directory when ignore is empty array", function(done) { + var w = new Watchpack({ + aggregateTimeout: 300, + ignored: [] + }); + var changeEvents = 0; + w.on("change", function(file) { + file.should.be.eql(path.join(fixtures, "a")); + changeEvents++; + }); + w.on("aggregated", function(changes) { + Array.from(changes).should.be.eql([path.join(fixtures, "a")]); + changeEvents.should.be.greaterThan(0); + w.close(); + done(); + }); + w.watch([path.join(fixtures, "a")], []); + testHelper.tick(function() { + testHelper.file("a"); + }); + }); + it("should watch a file then a directory", function(done) { var w = new Watchpack({ aggregateTimeout: 1000