joyent/node — Issue #1986: fs.watch not reporting events on osx
Author: wvl
Created: 2011-11-01 19:17:39+00:00
State: open

On osx (10.7), I'm not seeing the file events being reported from fs.watch when:

* using fs.writeFile to update a file (create works, as does a save from my editor)
* touch
* echo

fswatch.js: test case

```javascript

var fs = require('fs');
var D = require('util').debug;

fs.watch('tmp', function(event, filename) {
D("fs.watch event: "+event);
});

function write() {
D("Writing");
fs.writeFile("tmp/hello.txt", "Hello", function(err) {
D("Wrote file tmp/hello.txt");
});
}

setTimeout(write, 1000);
setTimeout(write, 2000);
```

On linux (ubuntu 11.10), node 0.5.10

```text
$ mkdir tmp
$ node fswatch.js &
[1] 4622
$ DEBUG: Writing
DEBUG: fs.watch event: rename
DEBUG: fs.watch event: change
DEBUG: Wrote file tmp/hello.txt
DEBUG: Writing
DEBUG: fs.watch event: change
DEBUG: fs.watch event: change
DEBUG: Wrote file tmp/hello.txt

$ touch tmp/hello.txt
DEBUG: fs.watch event: change
$ echo "world" >> tmp/hello.txt
$ DEBUG: fs.watch event: change
```

On osx (10.7), node 0.5.10

```text
> mkdir tmp
> node fswatch.js &
[1] 75764
> DEBUG: Writing
DEBUG: fs.watch event: rename
DEBUG: Wrote file tmp/hello.txt
DEBUG: Writing
DEBUG: Wrote file tmp/hello.txt

> touch tmp/hello.txt
> echo "hello" >> test.txt
> exit
```