Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (35 sloc) 1.29 KB
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
which = require 'which'
# ANSI Terminal Colors
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
reset = '\x1B[0m'
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', '-b', '-o', 'app', '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
task 'build', -> build -> log ":)", green
task 'dev', 'start dev env', ->
# watch_coffee
options = ['-c', '-b', '-w', '-o', 'app', 'src']
cmd = which.sync 'coffee'
coffee = spawn cmd, options
coffee.stdout.pipe process.stdout
coffee.stderr.pipe process.stderr
log 'Watching coffee files', green
# watch_js
supervisor = spawn 'node', ['./node_modules/supervisor/lib/cli-wrapper.js','-w','app,views', '-e', 'js|jade', 'server']
supervisor.stdout.pipe process.stdout
supervisor.stderr.pipe process.stderr
log 'Watching js files and running server', green