-
Notifications
You must be signed in to change notification settings - Fork 5
/
Cakefile
68 lines (57 loc) · 2.07 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
fs = require 'fs'
# Grab test files
walk = (dir, fileList) ->
list = fs.readdirSync(dir)
if list
for file in list
if file
filename = dir + '/' + file
stat = fs.statSync(filename)
if stat and stat.isDirectory()
walk(filename, fileList)
else if filename.substr(-6) == "coffee"
fileList.push(filename)
fileList
{exec} = require 'child_process'
testFiles = walk("test", [])
uiTestFiles = walk("client/test", [])
task 'tests', 'run tests through mocha', ->
runTests testFiles
task 'tests:client', 'run tests through mocha', ->
runTests uiTestFiles
runTests = (fileList) ->
console.log "Run tests with Mocha for " + fileList.join(" ")
command = "mocha " + fileList.join(" ") + " --reporter spec "
command += "--require should --compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
if err
console.log "Running mocha caught exception: \n" + err
console.log stdout
option '-f', '--file [FILE]', 'test file to run'
task 'tests:file', 'run test through mocha for a given file', (options) ->
file = options.file
console.log "Run tests with Mocha for " + file
command = "mocha " + file + " --reporter spec "
command += "--require should --compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
if err
console.log "Running mocha caught exception: \n" + err
console.log stdout
task "lint", "Run coffeelint on backend files", ->
process.env.TZ = "Europe/Paris"
command = "coffeelint -f coffeelint.json -r server.coffee server/"
exec command, (err, stdout, stderr) ->
console.log err
console.log stdout
task 'convert', 'Compile CoffeeScript into JavaScript (server)', ->
files = walk "server", []
console.log "Compilation..."
command = "coffee -cb server.coffee #{files.join ' '} "
exec command, (err, stdout, stderr) ->
console.log stdout
if err
console.log "Running compilation caught exception: \n" + err
process.exit 1
else
console.log "Sucessful compilation!"
process.exit 0