This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCakefile
68 lines (57 loc) · 2.09 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
fs = require 'fs'
{exec} = require 'child_process'
# Grab test files
walk = (dir, fileList) ->
list = fs.readdirSync dir
if list
for file in list
filename = dir + '/' + file
stat = fs.statSync filename
if stat and stat.isDirectory()
walk filename, fileList
else if filename.substr(-6) is "coffee"
fileList.push filename
fileList
testFiles = walk "test", []
task 'tests', 'run tests through mocha', ->
runTests testFiles
runTests = (fileList) ->
console.log "Run tests with Mocha for #{fileList.join(" ")}"
command = "mocha #{fileList.join(" ")} --reporter spec "
command += "--compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
console.log stdout
if err
console.log "Running mocha caught exception: \n" + err
process.exit 1
else
process.exit 0
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 += "--compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
if err
console.log "Running mocha caught exception: \n" + err
process.exit 1
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', 'convert from coffee to JS', ->
files = walk "server", []
console.log "Convert to JS..."
command = "coffee -cb server.coffee #{files.join ' '} "
exec command, (err, stdout, stderr) ->
console.log stdout
if err
console.log "Running convertion caught exception: \n" + err
process.exit 1
else
console.log "Convertion succeeded."
process.exit 0