When I --watch a directory containing coffeescript files, everything is caught- new files, immediate changes, but when I watch a handlebars directory it doesn't watch it. Am I right in thinking --watch is only available to coffee?
My Cakefile looks something like this:
{spawn} = require "child_process"
fs = require "fs"
handlebars = require "handlebars"
task 'watch', ->
spawn 'coffee', ['-cwj', 'js/libs/app.js', 'src/coffee']
spawn 'handlebars', ['-wf', 'js/libs/templates.js', 'tmpl']
How can I watch a custom directory using a Cakefile?
Yes, --watch
doesn't seem to be implemented by handlebars. You can use node's fs.watch
to hack up your own watcher. Here's how Coffeescript uses it to implement its own watch
functionality.
Personally, I like using Guard for watching files, even if I'm working on a non-Ruby project. It's easier to set up than fs.watch
.