0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/pummel/test-watch-file.js

27 lines
508 B
JavaScript
Raw Normal View History

require("../common");
2010-03-01 19:42:37 +01:00
var fs = require("fs");
var path = require("path");
var f = path.join(fixturesDir, "x.txt");
var f2 = path.join(fixturesDir, "x2.txt");
2009-11-17 14:52:18 +01:00
puts("watching for changes of " + f);
var changes = 0;
2010-03-01 19:42:37 +01:00
fs.watchFile(f, function (curr, prev) {
puts(f + " change");
changes++;
2010-02-17 23:30:50 +01:00
assert.ok(curr.mtime != prev.mtime);
2010-03-01 19:42:37 +01:00
fs.unwatchFile(f);
});
var fd = fs.openSync(f, "w+");
fs.writeSync(fd, 'xyz\n');
fs.closeSync(fd);
process.addListener("exit", function () {
2010-02-17 23:30:50 +01:00
assert.ok(changes > 0);
});