Skip to content

Instantly share code, notes, and snippets.

@topfunky
Created April 14, 2011 22:18
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save topfunky/920698 to your computer and use it in GitHub Desktop.
Save topfunky/920698 to your computer and use it in GitHub Desktop.
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