-
Notifications
You must be signed in to change notification settings - Fork 53
/
Cakefile
67 lines (51 loc) · 1.67 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
fs = require 'fs'
sys = require 'sys'
path = require 'path'
{exec} = require 'child_process'
UglifyJS = require 'uglify-js'
task 'compile', 'Compile coffee-script to JavaScript', ->
compile()
task 'test', 'Test this module', ->
test()
task 'build', 'Build this module', ->
build()
task 'minify', 'Minify the compiled javascript source', ->
minify()
compile = (callback) ->
console.log "Compiling..."
# Create the lib directory if it doesn't exist
if !fs.existsSync("lib")
fs.mkdirSync "lib"
# Compile the library
child = exec '"node_modules/.bin/coffee" -m -o lib ./src/lib/color-scheme.coffee', (err, stdout, stderr) ->
if err?
throw err
else
callback() if callback?
# Redirect the child process' output to our stdout
child.stdout.on 'data', (data) -> sys.print data
child.stderr.on 'data', (data) -> sys.print data
test = (callback) ->
console.log "Testing..."
child = exec '"node_modules/.bin/mocha" --reporter list --compilers coffee:coffee-script/register test', (err, stdout, stderr) ->
# console.log stdout
# console.log stderr
if err?
process.exit()
else
callback() if callback?
# Redirect the child process' output to our stdout
child.stdout.on 'data', (data) -> sys.print data
child.stderr.on 'data', (data) -> sys.print data
minify = (callback) ->
console.log "Minifying..."
compiled = UglifyJS.minify('lib/color-scheme.js')
fs.writeFileSync 'lib/color-scheme.min.js', compiled.code.toString()
callback() if callback?
# Run all the tasks one after the other!
build = (callback) ->
test () ->
compile () ->
minify () ->
console.log "Done!"
callback() if callback?