I\'m looking for simplest possible way to automatically recompile coffee scripts into JS.
Reading documentation but still having troubles to get exactly what I want.
Being one level above /src, this will work for all .coffee files found no matter the depth.
coffee -w -c src/
find `pwd` | grep .coffee | xargs coffee -w -c
try this one in root directory of the application
Changed mind about concatenation.
Created small compiler.sh file which contains:
dnotify -M src/ -e coffee -o lib/ -c src/ &
dnotify -M spec/ -e coffee -o lib/ -c spec/ &
Kind a suits my needs.
find -type f | grep .coffee | xargs ls -t | head -n 1 | xargs coffee -cw
find last modifed coffee script and put it in compile-watch mode
The short answer to your question is that the coffee
utility wasn't designed for this; combining file-watching and concatenation is actually pretty complex. Expect more sophisticated build tools for CoffeeScript in the near future; until then, you might want to do your project's builds by writing a Cakefile or Ruby Watchr script. Then you can also throw in minification, documentation-generation, and whatever else you need for your particular project (not to mention guaranteeing a particular concatenation order).
Well coffee --watch
has 2 major flaws:
git commit
itThe solution I came up with is a rather simple Bash script that takes coffee --watch
a few steps further which will allow your working directory tree to be watched ever since system login, and automatically get compiled into JavaScript on each file save/change
or new file creation:
http://blog.gantrithor.com/post/11609373640/carefree-coffeescript-auto-compiler
There may be more elegant way to do this, but this implementation works great =)