UNPKG

1.79 kBPlain TextView Raw
1child_process = require 'child_process'
2hound = require 'hound'
3
4docs = (after) ->
5 console.log 'docs...'
6 opts = ['src/*.coffee']
7 docco = child_process.spawn './node_modules/.bin/docco', opts
8 docco.stdout.pipe process.stdout
9 docco.stderr.pipe process.stderr
10 docco.on 'exit', -> after()
11
12build = (after) ->
13 console.log 'build...'
14 options = ['-c','-b', '-o', 'lib', 'src']
15 builder = child_process.spawn './node_modules/.bin/coffee', options
16 builder.stdout.pipe process.stdout
17 builder.stderr.pipe process.stderr
18 builder.on 'exit', -> after()
19
20runSpec = (fileOrFolder, after) ->
21 console.log 'run test...'
22 test_runner = child_process.spawn './node_modules/.bin/mocha', [
23 '--colors',
24 '--compilers',
25 'coffee:coffee-script',
26 fileOrFolder
27 ]
28 test_runner.stdout.pipe process.stdout
29 test_runner.stderr.pipe process.stderr
30 test_runner.on 'exit', -> after()
31
32changed = (file) ->
33 if match = file.match /(src|spec)\/(.+)(_spec)?.coffee/
34 spec_file = 'spec/' + match[2] + '_spec.coffee'
35 spec_file = file if match[1] == 'spec'
36 console.log 'Running: ', spec_file
37 runSpec spec_file, ->
38
39watchSrcDir = ->
40 console.log 'Watching ./src'
41 watcher = hound.watch './src'
42 watcher.on 'change', (file, stats) ->
43 return unless file.match /\.coffee$/
44 build -> changed file
45
46watchSpecDir = ->
47 console.log 'Watching ./spec'
48 watcher = hound.watch './spec'
49 watcher.on 'change', (file, stats) ->
50 changed file
51
52
53task 'dev', 'Run dev/spec', ->
54 watchSpecDir()
55 watchSrcDir()
56
57
58task 'spec', 'Run all tests', ->
59 build -> runSpec './spec', ->
60
61
62task 'build', 'Build', ->
63 build ->
64
65task 'doc', 'Docco build', ->
66 docs ->
67