UNPKG

883 BPlain TextView Raw
1{spawn, exec} = require 'child_process'
2log = console.log
3
4task 'build', ->
5 run 'coffee -o lib -c src/*.coffee'
6
7task 'test', ->
8 run 'cd test; coffee templateTests.coffee'
9
10task 'clean', ->
11 run 'npm remove -g coffin'
12
13task 'install', ->
14 run 'npm install -g .'
15
16task 'all', ->
17 run 'cake clean; cake test; cake build; cake install'
18
19run = (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