Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coffeescript 1.1.3 Watch only works once

I have nodejs v0.6.3 and coffeescript 1.1.3. on Archlinux.

I know they changed the way watch works in the latest release of coffeescript and that watch requires at least node v0.6.2.

In my case it only works once. After that when I save a file again, coffee does not take notice. What could be the problem here?

like image 914
hoodie Avatar asked Nov 26 '11 19:11

hoodie


1 Answers

There are a number of problems with fs.watch, which I've been actively discussing on both the Node and CoffeeScript issue trackers. One problem—likely the one you're encountering—is that some programs save changes not by writing directly to the existing file, but rather by writing to a temporary file and then mv-ing that file on top of the existing one. From fs.watch's perspective, this means that the watched file has been deleted, and changes to the new file will be ignored.

On the current CoffeeScript master, we try to work around this by re-watching the file each time a rename event is emitted. So please install that and let me know whether it solves your problem. If it doesn't, you should revert to using the older fs.watchFile API, either by downgrading to CoffeeScript 1.1.2 or by using a third-party tool like my own Jitter.

like image 177
Trevor Burnham Avatar answered Oct 17 '22 12:10

Trevor Burnham