Coffeescript and node-supervisor together?

I am using coffeescript with the --watch option to rebuild javascript when making changes to .coffee files.

Is it possible to combine this with node -supervisor to restart Node when changing compiled javascript?

I am worried that this will not be reliable due to atomicity when coffeescript recompiles multiple files. node -supervisor can jump the gun and restart Node when it detects the first file system change. Is it reliable enough to realize that there were additional changes when it was busy restarting Node?

Is there a better way? Ideally, I will have only one file system watcher recompiling my coffeescript and reloading node.

+5
source share
5 answers

You can use nodemon, it even has a delay function (to restart the server after a few seconds), for example:

nodemon --debug ./server.coffee 80

Another good feature of nodemon is to ignore files, for example:

# this is my ignore file with a nice comment at the top

/vendor/*     # ignore all external submodules
/public/*     # static files
./README.md   # a specific file
*.css         # ignore any CSS files too

Also, read the documentation on the github repo and watch this Nodetuts video about nodemon: http://nodetuts.com/tutorials/14-some-nodejs-tools.html

+6
source

Create a JavaScript start, i.e. run.js, eg:

require('coffee-script');
require('./launch');

Then run this file using the supervisor and related parameters:

supervisor -e "node|js|coffee" run.js

This worked well for me on Windows.

+7
source

supervisor -x, coffee. script :

supervisor -x coffee your-script.coffee

.

+4

Cakefiles, connect-assets, coffee -co lib src - , , . . .coffee ( coffee), JS .

+1

:

Procfile.dev

web: ./node_modules/supervisor/lib/cli-wrapper.js -n exit server.js
watch: ./node_modules/iced-coffee-script/bin/coffee --watch --compile server.iced

foreman start -f Procfile.dev

Then the gitignoreresulting files .js. I like this approach because it constantly updates the vanilla JAV file along with my files .iced, so I can double-check my work when I go (I definitely make coffeescript errors that may not be vanilla).

0
source

All Articles