fs.watchFile = function(filename) {
nullCheck(filename);
+ filename = pathModule.resolve(filename);
var stat;
var listener;
fs.unwatchFile = function(filename, listener) {
nullCheck(filename);
+ filename = pathModule.resolve(filename);
if (!inStatWatchers(filename)) return;
var stat = statWatchers[filename];
var watchSeenOne = 0;
var watchSeenTwo = 0;
var watchSeenThree = 0;
+var watchSeenFour = 0;
var startDir = process.cwd();
var testDir = common.tmpDir;
var filenameThree = 'charm'; // because the third time is
+var filenameFour = 'get';
process.on('exit', function() {
fs.unlinkSync(filepathOne);
fs.unlinkSync(filepathTwoAbs);
fs.unlinkSync(filenameThree);
+ fs.unlinkSync(filenameFour);
assert.equal(1, watchSeenOne);
assert.equal(2, watchSeenTwo);
assert.equal(1, watchSeenThree);
+ assert.equal(1, watchSeenFour);
});
setTimeout(function() {
fs.writeFileSync(filenameThree, 'pardner');
}, 1000);
+
+setTimeout(function() {
+ fs.writeFileSync(filenameFour, 'hey');
+}, 200);
+
+setTimeout(function() {
+ fs.writeFileSync(filenameFour, 'hey');
+}, 500);
+
+assert.doesNotThrow(
+ function() {
+ function a(curr, prev) {
+ ++watchSeenFour;
+ assert.equal(1, watchSeenFour);
+ fs.unwatchFile("." + path.sep + filenameFour, a);
+ }
+ fs.watchFile(filenameFour, a);
+ }
+);