blob: 05eb60ed6e8f9c830b17c836727e650b548dab9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var f = path.join(common.fixturesDir, 'x.txt');
var f2 = path.join(common.fixturesDir, 'x2.txt');
console.log('watching for changes of ' + f);
var changes = 0;
function watchFile() {
fs.watchFile(f, function(curr, prev) {
console.log(f + ' change');
changes++;
assert.ok(curr.mtime != prev.mtime);
fs.unwatchFile(f);
watchFile();
fs.unwatchFile(f);
});
}
watchFile();
var fd = fs.openSync(f, 'w+');
fs.writeSync(fd, 'xyz\n');
fs.closeSync(fd);
process.addListener('exit', function() {
assert.ok(changes > 0);
});
|