Watchers such as nodemon are great tools for easing the pain of testing, but they tend to be oriented towards specific tasks.
nodemon, for instance, Really Wants to be watching a directory and restarting an application script when it changes:
$ npm install nodemon $ nodemon app.js
On my first pass, we tried to take advantage of
-x, --exec flag for running scripts through alternative interpreters. And the good news is that
make counts. So long as the options passed to
-x are in the form
nodemon will happily run non-node applications
$ nodemon -x "make run -f" Makefile
Simple enough, right? It should be. But even though
nodemon is happy to run
make, it isn’t so good about terminating the child processes spawned by
make. Outside of Windows,
child_process.kill to restart the application. That’s good enough to get
make, but it won’t actually kill the
coffee process started in the Makefile.
Our second attempt opted for the inelegant strategy of compiling from within the app. This time, we patched the main script (we’re using express) to run make when the script is run inside the development environment:
# in app.coffee app.configure 'development', -> child_process = require 'child_process' child_process.exec 'make', ['generate-js']
.nodemonignore to overlook the compiled files in
Coffee compiles. App launches. Ship it.