Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (45 sloc) 1.952 kb
4367f67 @TrevorBurnham Initial commit, spinning off this part of connect-assets
authored
1 fs = require 'fs'
b244d1f @TrevorBurnham Updating Cakefile for node 0.6+
authored
2 {print} = require 'util'
4367f67 @TrevorBurnham Initial commit, spinning off this part of connect-assets
authored
3 {spawn, exec} = require 'child_process'
b244d1f @TrevorBurnham Updating Cakefile for node 0.6+
authored
4 watchit = require 'watchit'
4367f67 @TrevorBurnham Initial commit, spinning off this part of connect-assets
authored
5
6 build = (watch, callback) ->
7 if typeof watch is 'function'
8 callback = watch
9 watch = false
10 options = ['-c', '-o', 'lib', 'src']
11 options.unshift '-w' if watch
12
13 coffee = spawn 'coffee', options
14 coffee.stdout.on 'data', (data) -> print data.toString()
15 coffee.stderr.on 'data', (data) -> print data.toString()
16 coffee.on 'exit', (status) -> callback?() if status is 0
17
18 task 'docs', 'Generate annotated source code with Docco', ->
19 fs.readdir 'src', (err, contents) ->
20 files = ("src/#{file}" for file in contents when /\.coffee$/.test file)
21 docco = spawn 'docco', files
22 docco.stdout.on 'data', (data) -> print data.toString()
23 docco.stderr.on 'data', (data) -> print data.toString()
24 docco.on 'exit', (status) -> callback?() if status is 0
25
26 task 'build', 'Compile CoffeeScript source files', ->
27 build()
28
29 task 'watch', 'Recompile CoffeeScript source files when modified', ->
30 build true
31
32 task 'test', 'Run the test suite (and re-run if anything changes)', ->
33 suite = null
34 build ->
35 do runTests = ->
36 suite?.kill()
37 suiteNames = ['test']
38 suiteIndex = 0
39 do runNextTestSuite = ->
40 return unless suiteName = suiteNames[suiteIndex]
41 suite = spawn "coffee", ["-e", "{reporters} = require 'nodeunit'; reporters.default.run ['#{suiteName}.coffee']"], cwd: 'test'
42 suite.stdout.on 'data', (data) -> print data.toString()
43 suite.stderr.on 'data', (data) -> print data.toString()
44 suite.on 'exit', -> suiteIndex++; runNextTestSuite()
45 invoke 'docs' # lest I forget
b244d1f @TrevorBurnham Updating Cakefile for node 0.6+
authored
46 watchTargets = (targets..., callback) ->
47 for target in targets
48 watchit target, include: true, (event) ->
49 callback() unless event is 'success'
50 watchTargets 'src', -> build runTests
51 watchTargets 'test', 'Cakefile', runTests
Something went wrong with that request. Please try again.