forked from natlownes/quips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
64 lines (51 loc) · 1.53 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
fs = require 'fs'
{spawn, exec} = require 'child_process'
{log, error, print} = require 'util'
localBin = "./node_modules/.bin/"
sh = (cmd, cb) ->
proc = exec cmd, (err, stdout, stderr) ->
process.stdout.write stdout if stdout
process.stderr.write stderr if stderr
throw err if err
process.exit proc.exitCode if proc.exitCode
cb? proc
task 'dev:server', 'run frontend and mock backend', ->
server = sh 'coffee dev_server.coffee'
# TODO
frontend = sh ''
task 'clean:test', 'clean tmp dir', (options, cb) ->
sh 'rm -rf tmp/*'
task 'haml:compile:test', 'compile haml templates', (options, cb) ->
sh 'cake clean:test', ->
sh "#{localBin}haml-coffee -i test -o tmp/templates.js"
task 'tags', 'ctags', (options, cb) ->
sh 'ctags -R .'
mochaExec = ->
"#{localBin}mocha"
option '-f', '--files [PATHS]', 'only run specific files'
option '-w', '--watch', 'watch'
task 'test', 'mocha tests', (options, cb) ->
testDependencies = [
"./test/setup.coffee"
"./tmp/templates"
]
files = options.files || "./test"
cmd = "node"
mochaArgs = [
mochaExec(),
'-c'
'--compilers'
'coffee:coffee-script'
'--recursive'
'-u'
'bdd'
]
mochaArgs.push('-w') if options.watch?
mochaArgs.push(filePath) for filePath in testDependencies
mochaArgs.push(files)
sh "cake haml:compile:test", ->
mocha = spawn cmd, mochaArgs
mocha.stdout.on 'data', (data) ->
print data.toString()
mocha.stderr.on 'data', (data) ->
console.log data.toString()