1 | {spawn, exec} = require 'child_process'
|
2 |
|
3 | launch = (cmd, options=[], done=null) ->
|
4 | app = spawn cmd, options
|
5 | app.stdout.pipe(process.stdout)
|
6 | app.stderr.pipe(process.stderr)
|
7 | app.on 'exit', (status) ->
|
8 | err = if status isnt 0 then new Error("Error running #{cmd}") else null
|
9 | done? err
|
10 |
|
11 | build = (done) ->
|
12 | console.log "Building"
|
13 | exec './node_modules/.bin/coffee --compile --output lib/ src/', (err, stdout, stderr) ->
|
14 | process.stderr.write stderr
|
15 | return done err if err
|
16 |
|
17 | process.stderr.write stderr
|
18 | done?()
|
19 |
|
20 | mocha = (done) ->
|
21 | console.log "Testing"
|
22 | launch './node_modules/.bin/mocha', ['test'], done
|
23 |
|
24 | run = (fn) ->
|
25 | ->
|
26 | fn (err) ->
|
27 | console.log err.stack if err
|
28 |
|
29 | task 'build', "Build project from src/*.coffee to lib/*.js", run build
|
30 | task 'test', "Run mocha tests", run -> build mocha
|