-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
69 lines (55 loc) · 1.68 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
casua_files = [
'build'
'src'
]
qunit_files = [
'.tmp/test'
'test'
]
examples_files = [
'examples'
'examples'
]
doc_files = [
'doc'
'doc'
]
{spawn, exec} = require 'child_process'
try
which = require('which').sync
catch err
if process.platform.match(/^win/)?
console.log 'WARNING: the which module is required for windows\ntry: npm install which'
which = null
# ANSI Terminal Colors
bold = '\x1b[0;1m'
green = '\x1b[0;32m'
reset = '\x1b[0m'
red = '\x1b[0;31m'
task 'compile', 'compile', -> compile -> log ":-)", green
task 'watch', 'compile and watch', -> compile true, -> log ":-)", green
task 'build', 'compile and build', -> compile -> build -> log ":-)", green
task 'doc', 'update doc file', -> compile -> build -> doc -> log ":-)", green
log = (message, color, explanation) -> console.log color + message + reset + ' ' + (explanation or '')
launch = (cmd, options=[], callback) ->
cmd = which(cmd) if which
app = spawn cmd, options
app.stdout.pipe(process.stdout)
app.stderr.pipe(process.stderr)
app.on 'exit', (status) -> callback?() if status is 0
compile = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-c', '-o']
if watch
options.unshift '-w'
launch 'coffee', options.concat qunit_files
launch 'coffee', options.concat examples_files
launch 'coffee', options.concat doc_files
launch 'coffee', options.concat(casua_files), callback
build = (callback) ->
exec 'uglifyjs build/casua.js -o build/casua.min.js -c --mangle toplevel,eval -r "ct,sc,mm"', [], callback
doc = (callback) ->
exec 'coffee ./doc/generate.coffee', [], ->
launch 'cp', ['-f', 'doc/doc.css', 'gh-pages/'], callback