/
Cakefile
67 lines (53 loc) · 1.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
child_process = require 'child_process'
hound = require 'hound'
docs = (after) ->
console.log 'docs...'
opts = ['src/*.coffee']
docco = child_process.spawn './node_modules/.bin/docco', opts
docco.stdout.pipe process.stdout
docco.stderr.pipe process.stderr
docco.on 'exit', -> after()
build = (after) ->
console.log 'build...'
options = ['-c','-b', '-o', 'lib', 'src']
builder = child_process.spawn './node_modules/.bin/coffee', options
builder.stdout.pipe process.stdout
builder.stderr.pipe process.stderr
builder.on 'exit', -> after()
runSpec = (fileOrFolder, after) ->
console.log 'run test...'
test_runner = child_process.spawn './node_modules/.bin/mocha', [
'--colors',
'--compilers',
'coffee:coffee-script',
fileOrFolder
]
test_runner.stdout.pipe process.stdout
test_runner.stderr.pipe process.stderr
test_runner.on 'exit', -> after()
changed = (file) ->
if match = file.match /(src|spec)\/(.+)(_spec)?.coffee/
spec_file = 'spec/' + match[2] + '_spec.coffee'
spec_file = file if match[1] == 'spec'
console.log 'Running: ', spec_file
runSpec spec_file, ->
watchSrcDir = ->
console.log 'Watching ./src'
watcher = hound.watch './src'
watcher.on 'change', (file, stats) ->
return unless file.match /\.coffee$/
build -> changed file
watchSpecDir = ->
console.log 'Watching ./spec'
watcher = hound.watch './spec'
watcher.on 'change', (file, stats) ->
changed file
task 'dev', 'Run dev/spec', ->
watchSpecDir()
watchSrcDir()
task 'spec', 'Run all tests', ->
build -> runSpec './spec', ->
task 'build', 'Build', ->
build ->
task 'doc', 'Docco build', ->
docs ->