Comparing version 0.1.3 to 0.2.0
@@ -24,2 +24,4 @@ /* | ||
persistent: true, | ||
followSymlinks: false, | ||
depth: 0, | ||
ignorePermissionErrors: true | ||
@@ -50,2 +52,3 @@ }); | ||
if(!old) { | ||
if(initial) return; | ||
if(mtime) { | ||
@@ -178,3 +181,3 @@ if(this.watchers[path]) { | ||
if(/[\\\/]/.test(path.substr(this.path.length + 1))) return; | ||
if(!stat) { | ||
@@ -313,2 +316,2 @@ return fs.stat(path, function(err, stat) { | ||
this.emit("closed"); | ||
}; | ||
}; |
{ | ||
"name": "watchpack", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -23,11 +23,11 @@ "main": "./lib/watchpack.js", | ||
"devDependencies": { | ||
"mocha": "^1.20.1", | ||
"mocha": "^2.1.0", | ||
"rimraf": "^2.2.8", | ||
"should": "^4.0.4" | ||
"should": "^4.6.0" | ||
}, | ||
"dependencies": { | ||
"async": "^0.9.0", | ||
"chokidar": "^0.11.0", | ||
"chokidar": "^0.12.0", | ||
"graceful-fs": "^3.0.2" | ||
} | ||
} |
@@ -10,3 +10,3 @@ var should = require("should"); | ||
describe("DirectoryWatcher", function() { | ||
this.timeout(5000); | ||
this.timeout(10000); | ||
beforeEach(testHelper.before); | ||
@@ -27,3 +27,3 @@ afterEach(testHelper.after); | ||
}); | ||
it("should detect a file change", function(done) { | ||
@@ -42,3 +42,3 @@ var d = new DirectoryWatcher(fixtures); | ||
}); | ||
it("should not detect a file change in initial scan", function(done) { | ||
@@ -58,3 +58,3 @@ testHelper.file("a"); | ||
}); | ||
it("should detect a file change in initial scan with start date", function(done) { | ||
@@ -72,3 +72,3 @@ var start = new Date(); | ||
}); | ||
it("should detect a file change in initial scan without start date", function(done) { | ||
@@ -88,3 +88,3 @@ testHelper.file("a"); | ||
}); | ||
it("should detect multiple file changes", function(done) { | ||
@@ -117,2 +117,2 @@ var d = new DirectoryWatcher(fixtures); | ||
}); | ||
}); | ||
}); |
@@ -53,8 +53,10 @@ var fs = require("fs"); | ||
TestHelper.prototype.tick = function tick(fn) { | ||
// setTimeout(fn, 100); | ||
TestHelper.prototype.tick = function tick(arg, fn) { | ||
if(typeof arg === "function") { | ||
fn = arg; | ||
arg = 100; | ||
} | ||
setTimeout(function() { | ||
// console.log("tick"); | ||
fn(); | ||
}, 100); | ||
}; | ||
}, arg); | ||
}; |
@@ -10,3 +10,3 @@ var should = require("should"); | ||
describe("Watchpack", function() { | ||
this.timeout(5000); | ||
this.timeout(10000); | ||
beforeEach(testHelper.before); | ||
@@ -143,3 +143,3 @@ afterEach(testHelper.after); | ||
w2.watch([path.join(fixtures, "a")], []); | ||
testHelper.tick(function() { | ||
testHelper.tick(1000, function() { // wait for initial scan | ||
testHelper.mtime("a", Date.now() + 1000000); | ||
@@ -159,2 +159,82 @@ testHelper.tick(function() { | ||
}); | ||
it("should detect a past change to a file (timestamp)", function(done) { | ||
var w = new Watchpack({ | ||
aggregateTimeout: 1000 | ||
}); | ||
var changeEvents = 0; | ||
w.on("change", function(file, mtime) { | ||
file.should.be.eql(path.join(fixtures, "a")); | ||
changeEvents++; | ||
}); | ||
w.on("aggregated", function(changes) { | ||
changes.should.be.eql([path.join(fixtures, "a")]); | ||
changeEvents.should.be.eql(1); | ||
w.close(); | ||
done(); | ||
}); | ||
var startTime = Date.now(); | ||
testHelper.tick(function() { | ||
testHelper.file("a"); | ||
testHelper.tick(function() { | ||
w.watch([path.join(fixtures, "a")], [], startTime); | ||
}); | ||
}); | ||
}); | ||
it("should not detect a past change to a file (watched)", function(done) { | ||
var w2 = new Watchpack(); | ||
var w = new Watchpack(); | ||
w.on("change", function(file, mtime) { | ||
throw new Error("Should not be detected"); | ||
}); | ||
testHelper.tick(function() { | ||
testHelper.file("b"); | ||
w2.watch([path.join(fixtures, "b")], []) | ||
testHelper.tick(1000, function() { // wait for stable state | ||
testHelper.file("a"); | ||
testHelper.tick(function() { | ||
var startTime = Date.now(); | ||
testHelper.tick(function() { | ||
w.watch([path.join(fixtures, "a")], [], startTime); | ||
testHelper.tick(function() { | ||
w.close(); | ||
w2.close(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it("should detect a past change to a file (watched)", function(done) { | ||
var w2 = new Watchpack(); | ||
var w = new Watchpack(); | ||
var changeEvents = 0; | ||
w.on("change", function(file, mtime) { | ||
file.should.be.eql(path.join(fixtures, "a")); | ||
changeEvents++; | ||
}); | ||
w.on("aggregated", function(changes) { | ||
changes.should.be.eql([path.join(fixtures, "a")]); | ||
changeEvents.should.be.eql(1); | ||
w.close(); | ||
w2.close(); | ||
done(); | ||
}); | ||
testHelper.tick(function() { | ||
testHelper.file("b"); | ||
w2.watch([path.join(fixtures, "b")], []) | ||
testHelper.tick(function() { | ||
var startTime = Date.now(); | ||
testHelper.tick(function() { | ||
testHelper.file("a"); | ||
testHelper.tick(function() { | ||
w.watch([path.join(fixtures, "a")], [], startTime); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28359
835
+ Addedchokidar@0.12.6(transitive)
+ Addedreaddirp@1.3.0(transitive)
- Removedchokidar@0.11.1(transitive)
- Removedreaddirp@1.1.0(transitive)
Updatedchokidar@^0.12.0