Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (24 sloc) 845 Bytes
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
# ANSI Terminal Colors
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
reset = '\x1B[0m'
task 'build', ->
build log("Finished building project", green)
task 'watch', ->
build true, log("Watching CoffeeScript files ...", bold)
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-c', '-o', 'build', 'src']
options.unshift '-w' if watch
coffee = spawn 'coffee', options
coffee.stdout.on 'data', (data) -> print data.toString()
coffee.stderr.on 'data', (data) -> log data.toString(), red
coffee.on 'exit', (status) -> callback?() if status is 0