Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Watch both Sass and Coffee files and compile on change (for Node.js)
###
Modified from https://github.com/jashkenas/coffee-script/blob/master/Cakefile
Part of an upcoming PeepCode screencast. This snippet is MIT Licensed.
###
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args) ->
proc = spawn name, args
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.stdout.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) -> process.exit(1) if status != 0
runCommand 'sass', ['--watch', 'public/css/sass:public/css']
runCommand 'coffee', ['-wc', 'public/js', 'test-js']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment