I have a small web service developed in node, and I'd like to code some files in coffeescript, to start playing with it.
I'm using nodemon to run the app, like this
nodemon app.js
And I have the following file structure
app.js controllers/ ping.coffee test.js
In nodemon's homepage it says that it supports coffeescript, but I change the file and it won't get reloaded.
Then I found this article, so I tried with
$ coffee --watch --compile ./controllers/*.coffee
And it works fine, but if I try with
$ coffee --watch --compile ./*.coffee
File not found: ./*.coffee
So it seems like the watch option is not recursive.
Any idea how can I make nodemon pick coffeescript files changes, or have the coffee compiler pick files recursively?
What you're doing is pretty common in coffeescript libraries. Many libraries have a script to compile all coffeescript files in one directory to Javascript files in another. For example, the following
Cakefile
compiles fromsrc/
tolib/
. You cancake watch
orcake build
depending on what you want to do.However, if you're not running node but actually running a browser app, I would suggest using the fantastic hem. For that, I've also written a getting-started guide on here: https://stackoverflow.com/a/14993583/586086
Nodemon will properly watch the coffeescript files if you explicitly specify their extension with
-e js,coffee
. This is counter to what the docs state and I've filed a ticket on this issue here: https://github.com/remy/nodemon/issues/312This should work:
Also, you can shorten the flags to
-wc
.