-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
84 lines (70 loc) · 2.25 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
target = 'js/editor.js'
sources = [
'list',
'stroke',
'polygon',
'helper',
'scribble'
'evaluate',
'fuzzy',
'gesture',
'command',
'shape',
'line',
'rectangle',
'circle',
'delete',
'recognizer'
].map (f) -> 'src/'+f+'.coffee'
# ANSI Terminal Colors
bold = '1'#'\033[0;1m'
green = '1'#'\033[0;32m'
reset = '1'#'\033[0m'
red = '1'#'\033[0;31m'
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-j', 'lib/cali.js', '-cb']
options.unshift '-w' if watch
options = options.concat sources
coffee = spawn 'coffee', options
coffee.stdout.on 'data', (data) -> print data.toString()
coffee.stderr.on 'data', (data) -> print data.toString()
coffee.on 'exit', (status) -> callback?() if status is 0
spec = (callback) ->
require 'jasmine-node'
jasmine.executeSpecsInFolder(
__dirname + '/spec',
(runner, log) -> process.exit(runner.results().failedCount), # callback
true, # isVerbose
true, # showColors
false, # teamcity
false, # use requirejs
new RegExp(".spec\\.coffee$", 'i'), #regex
false, # junit
)
task 'docs', 'Generate annotated source code with Docco', ->
fs.readdir 'src', (err, contents) ->
files = ("src/#{file}" for file in contents when /\.coffee$/.test file)
docco = spawn 'docco', files
docco.stdout.on 'data', (data) -> print data.toString()
docco.stderr.on 'data', (data) -> print data.toString()
docco.on 'exit', (status) -> callback?() if status is 0
task 'build', 'Compile CoffeeScript source files', ->
build()
task 'watch', 'Recompile CoffeeScript source files when modified', ->
build true
task 'test', 'Run the test suite', ->
build -> spec -> log ":)", green
task 'dist', 'Build final js', ->
exec "./node_modules/.bin/browserify src/recognizer.coffee -o dist/cali.js", (err, stdout, stderr) ->
throw err if err
out = stdout + stderr
console.log out if out != ''
callback() if callback?