-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCakefile
74 lines (63 loc) · 2.68 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
69
70
71
72
73
74
_ = require 'underscore'
require 'icing'
path = require 'path'
fs = require 'fs'
{exec} = require 'child_process'
module_path = path.dirname fs.realpathSync __filename # Cakefile path == process.cwd()
option '-t','--tap','Run tests with tap output'
# choose config, dev or prod, choosing from config ... process.env.NODE_ENV=test
# options.verbose applied to tests
task 'version', 'version', ->
package = require "./package.coffee"
console.log package.version
task 'compile_config', 'Convert package.coffee to package.json',
['package.coffee', 'config/config.coffee'],
recipe: ->
exec "coffee -c package.coffee", (error) =>
# compile to js first. the internal compile may not be done before import
package = require "./package.js"
package_json_path = path.join module_path, 'package.json'
try
fs.writeFileSync package_json_path, (JSON.stringify package, null, 4)
fs.unlinkSync path.join module_path, 'package.js'
this.finished()
catch error
this.failed error
this.exec [
"coffee -c -o config/ config/config.coffee"
]
outputs: ->
['package.json', 'config/config.js'] # package_json_path but icing compares strings??
task 'compile_src', 'Compile from coffeescript in src to js in lib',
['src/*.coffee'],
recipe: ->
this.exec [
"coffee -c -o lib/ #{this.modifiedPrereqs.join(' ')}"
]
outputs: ->
for prereq in this.filePrereqs
prereq.replace /src\/(.*).coffee/,"lib/$1.js" # note: returns [ ] of modified prereq
task 'compile_tests', 'Compile tests from cs to js',
['test/config-tests.coffee', 'test/server/*.coffee', 'test/browser/*.coffee'],
recipe: ->
this.exec [
"coffee -c -o test/ test/config-tests.coffee"
"coffee -c -o test/browser/ test/browser/*.coffee"
"coffee -c -o test/server/ test/server/*.coffee"
]
outputs: (options) ->
for prereq in this.filePrereqs
prereq.replace /(.*).coffee/,"$1.js"
task 'compile', 'Compile config, tests, and source',
['task(compile_config)', 'task(compile_tests)', 'task(compile_src)'], (options) ->
this.finished()
task 'test_server', 'Run server tests', ['task(compile)'], (options) ->
command = "./node_modules/buster/bin/buster test --config test/config-tests.js -e node"
this.exec [
command
]
task 'test_browser', 'Run browser tests', ['task(compile)'], (options) ->
command = "./node_modules/buster/bin/buster test --config test/config-tests.js -e browser"
this.exec [
command
]