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', ->
|
8 | run 'cd test; coffee templateTests.coffee'
|
9 |
|
10 | task 'clean', ->
|
11 | run 'npm remove -g coffin'
|
12 |
|
13 | task 'install', ->
|
14 | run 'npm install -g .'
|
15 |
|
16 | task 'all', ->
|
17 | run 'cake clean; cake test; cake build; cake install'
|
18 |
|
19 | run = (args...) ->
|
20 | for a in args
|
21 | switch typeof a
|
22 | when 'string' then command = a
|
23 | when 'object'
|
24 | if a instanceof Array then params = a
|
25 | else options = a
|
26 | when 'function' then callback = a
|
27 |
|
28 | command += ' ' + params.join ' ' if params?
|
29 | cmd = spawn '/bin/sh', ['-c', command], options
|
30 | cmd.stdout.on 'data', (data) -> process.stdout.write data
|
31 | cmd.stderr.on 'data', (data) -> process.stderr.write data
|
32 | process.on 'SIGHUP', -> cmd.kill()
|
33 | cmd.on 'exit', (code) -> callback() if callback? and code is 0
|