1 | {spawn, exec} = require 'child_process'
|
2 | log = console.log
|
3 |
|
4 | task 'build', ->
|
5 | run 'coffee -o lib -c src/*.coffee'
|
6 |
|
7 | task 'test', -> require('./test').run()
|
8 |
|
9 | task 'bench', -> require('./benchmark').run()
|
10 |
|
11 | task 'docs', ->
|
12 | run 'docco src/coffeecup.coffee'
|
13 |
|
14 | run = (args...) ->
|
15 | for a in args
|
16 | switch typeof a
|
17 | when 'string' then command = a
|
18 | when 'object'
|
19 | if a instanceof Array then params = a
|
20 | else options = a
|
21 | when 'function' then callback = a
|
22 |
|
23 | command += ' ' + params.join ' ' if params?
|
24 | cmd = spawn '/bin/sh', ['-c', command], options
|
25 | cmd.stdout.on 'data', (data) -> process.stdout.write data
|
26 | cmd.stderr.on 'data', (data) -> process.stderr.write data
|
27 | process.on 'SIGHUP', -> cmd.kill()
|
28 | cmd.on 'exit', (code) -> callback() if callback? and code is 0
|