Skip to content

Commit

Permalink
Merge pull request #52 from omgftw/master
Browse files Browse the repository at this point in the history
Fixed watch for directories containing special glob characters
  • Loading branch information
TheLarkInn committed Jul 7, 2017
2 parents ebcdc81 + 689f6b4 commit 8b37d6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/DirectoryWatcher.js
Expand Up @@ -56,7 +56,8 @@ function DirectoryWatcher(directoryPath, options) {
ignorePermissionErrors: true,
ignored: options.ignored,
usePolling: options.poll ? true : undefined,
interval: typeof options.poll === "number" ? options.poll : undefined
interval: typeof options.poll === "number" ? options.poll : undefined,
disableGlobbing: true
});
this.watcher.on("add", this.onFileAdded.bind(this));
this.watcher.on("addDir", this.onDirectoryAdded.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"async": "^2.1.2",
"chokidar": "^1.4.3",
"chokidar": "^1.7.0",
"graceful-fs": "^4.1.2"
}
}
30 changes: 30 additions & 0 deletions test/Watchpack.js
Expand Up @@ -338,6 +338,36 @@ describe("Watchpack", function() {
});
});

it("should watch file in a directory that contains special glob characters", function(done) {
var w = new Watchpack({
aggregateTimeout: 1000
});
var changeEvents = [];
w.on("change", function(file) {
if(changeEvents[changeEvents.length - 1] === file)
return;
changeEvents.push(file);
});
w.on("aggregated", function(changes) {
changes.should.be.eql([path.join(fixtures, "dir")]);
changeEvents.should.be.eql([path.join(fixtures, "dir", "sub()", "a")]);
var times = w.getTimes();
times[path.join(fixtures, "dir")].should.be.type("number");
times[path.join(fixtures, "dir")].should.be.eql(times[path.join(fixtures, "dir", "sub()", "a")]);
times[path.join(fixtures, "dir", "sub()")].should.be.eql(times[path.join(fixtures, "dir", "sub()", "a")]);
w.close();
done();
});
testHelper.dir("dir");
testHelper.dir(path.join("dir", "sub()"));
testHelper.tick(function() {
w.watch([], [path.join(fixtures, "dir")]);
testHelper.tick(function() {
testHelper.file(path.join("dir", "sub()", "a"));
});
});
});

it("should detect a single change to future timestamps", function(done) {
var w = new Watchpack({
aggregateTimeout: 1000
Expand Down

0 comments on commit 8b37d6a

Please sign in to comment.