This repository has been archived by the owner on Sep 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCakefile
49 lines (39 loc) · 1.81 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
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
# ANSI Terminal Colors
bold = '\x33[0;1m'
green = '\x33[0;32m'
reset = '\x33[0m'
red = '\x33[0;31m'
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
print = (data) -> console.log data.toString().trim()
handleError = (err) ->
if err
#console.log "\n\x33[1;36m=>\x33[1;37m Remember that you need: [email protected] and [email protected]\x33[0;37m\n"
log "Remember that you need: [email protected] and [email protected]", red
console.log err.stack
task 'install', 'Executes an install of the required packages.', ->
exec 'npm install'
task 'build', 'Compile Coffeescript source to Javascript', ->
exec 'mkdir -p lib && coffee -c -o lib src', handleError
exec 'find lib -name "*.js" -print0 | xargs -0 jslint --stupid'
task 'clean', 'Remove generated Javascripts', ->
exec 'rm -fr lib', handleError
task 'test', 'Test the app', (options) ->
console.log "\n\x1B[00;33m=>\x1B[00;32m Running tests..\x1B[00;33m\n"
mocha = spawn 'mocha', '-c -b --compilers coffee:coffee-script -R spec'.split(' ')
mocha.stdout.on 'data', (data) -> print data.toString()
mocha.stderr.on 'data', (data) -> log data.toString(), red
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) -> log data.toString(), red
docco.on 'exit', (status) -> callback?() if status is 0
task 'dev', 'Continuous compilation', ->
coffee = spawn 'coffee', '-wc --bare -o lib src'.split(' ')
coffee.stdout.on 'data', print
coffee.stderr.on 'data', print