-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCakefile
42 lines (35 loc) · 1.48 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
flour = require 'flour'
cp = require 'child_process'
mochaArgs = [
'--compilers', 'coffee:coffee-script'
'-r', 'test/common'
'-c'
]
mochaPath = 'node_modules/mocha/bin/mocha'
task 'build', "Compile the source files to into lib/", ->
for file in ['Bot', 'Message', 'UserDB', 'regex', 'index']
compile "src/#{file}.coffee", "lib/#{file}.js"
task 'test', "Run the tests using mocha", ->
invoke 'build'
args = mochaArgs.concat ['--reporter', 'spec']
cp.spawn mochaPath, args, {stdio: 'inherit'}
task 'coverage', "Generate code coverage report using jscoverage (saved as coverage.html)", ->
invoke 'build'
jscov = cp.spawn 'jscoverage', ['--no-highlight', 'lib', 'lib-cov'], {stdio: 'inherit'}
jscov.on 'exit', (code, signal) ->
if code is 0 and not signal?
file = require('fs').createWriteStream 'coverage.html'
args = mochaArgs.concat ['--reporter', 'html-cov']
process.env['BOTER_COV'] = 1
mocha = cp.spawn mochaPath, args
mocha.stdout.pipe file
mocha.on 'exit', -> cp.spawn 'rm', ['-r', 'lib-cov']
task 'watch', "Watch src/ and test/ and run 'test' when anything changes", ->
invoke 'watch-src'
args = mochaArgs.concat ['--watch', '--reporter', 'min', '-G']
cp.spawn mochaPath, args, {stdio: 'inherit'}
task 'watch-src', "Watch src/ and run 'build' when anything changes", ->
invoke 'build'
watch 'src/', -> invoke 'build'
task 'make', "Alias for 'build'", -> invoke 'build'
task 'cov', "Alias for 'coverage'", -> invoke 'coverage'