-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
44 lines (36 loc) · 1.46 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{spawn} = require('child_process')
testutil = require('testutil')
if process.platform is 'darwin'
growl = require('growl')
option '-g', '--grep [PATTERN]', 'only run tests matching <pattern>'
task 'build', 'build lib/ from src/', ->
coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) -> process.stderr.write data.toString()
coffee.stdout.on 'data', (data) -> process.stdout.write data.toString()
coffee.on 'exit', (code) ->
if code is 0
console.log 'Successfully built.'
else
console.log "Error building. Code: #{code}"
task 'test', 'test project', (options) ->
process.env['NODE_ENV'] = 'test'
testutil.fetchTestFiles './test', (files) ->
files.unshift '--colors'
if options.grep?
files.unshift options.grep
files.unshift '--grep'
mocha = spawn 'mocha', files#, customFds: [0..2]
mocha.stdout.pipe(process.stdout, end: false);
mocha.stderr.pipe(process.stderr, end: false);
task 'watch', 'Watch src/ for changes', ->
coffee = spawn 'coffee', ['-w', '-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) -> 'ERR: ' + process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
d = data.toString()
if d.indexOf('compiled') > 0
#invoke 'test'
do (->)
else
if growl? then growl(d, title: 'Error', image: './resources/error.png')
process.stdout.write data.toString()
#mocha = spawn 'mocha', ['-w']