Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created February 12, 2012 17:11
Show Gist options
  • Save fukayatsu/1809676 to your computer and use it in GitHub Desktop.
Save fukayatsu/1809676 to your computer and use it in GitHub Desktop.
srcディレクトリに変更があったらビルドして、成功したらテストする
fs = require 'fs'
{print} = require 'util'
{spawn} = require 'child_process'
build = (callback) ->
coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
coffee.on 'exit', (code) ->
callback?() if code is 0
task 'build', 'Build lib/ from src/', ->
build()
task 'watch', 'Watch src/ for changes', ->
coffee = spawn 'coffee', ['-w', '-c', '-o', 'lib', 'src']
#build failed
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
#build SUCCESS
coffee.stdout.on 'data', (data) ->
print data.toString()
#testing
jasmine = spawn 'jasmine-node', ['--coffee', 'spec']
jasmine.stderr.on 'data', (data) ->
process.stderr.write data.toString()
jasmine.stdout.on 'data', (data) ->
print data.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment