forked from cqframework/cql-execution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
93 lines (77 loc) · 2.91 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
fs = require 'fs'
browserify = require 'browserify'
babelify = require 'babelify'
{spawn, exec} = require 'child_process'
build = (src, dest, watch = false) ->
args = ['-c', '-m', '-o', dest, src]
if watch then args.unshift '-w'
coffee = spawn 'coffee', args
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
console.log data.toString()
coffee.on 'exit', (code) ->
console.log "Completed transpiling #{src} to #{dest}, exit code #{code}"
buildTestData = (watch = false) ->
args = if watch then ['watchTestData'] else ['generateTestData']
gradle = spawn './gradlew', args, cwd: "./test/generator"
gradle.stderr.on 'data', (data) ->
process.stderr.write data.toString()
gradle.stdout.on 'data', (data) ->
console.log data.toString()
task 'build', 'Build lib/ and lib-test/ from src/ and test/', ->
build('src', 'lib')
build('test', 'lib-test')
task 'build-test-data', 'Build test/data/cql-test-data.coffee from test/data/cql-test-data.txt', ->
buildTestData()
task "build-all", "Build src/, test/ and test/data/cql-test-data.txt", ->
invoke 'build'
invoke 'build-test-data'
task "build-cql4browsers", "Builds the cql4browsers.js file", ->
console.log 'Browserifing cql4browsers...'
outputJsFile = fs.createWriteStream('./src/example/browser/cql4browsers.js')
browserify('./lib/example/browser/simple-browser-support.js')
.transform(babelify,
global: true
only: /node_modules\/ucum\//,
plugins: ["transform-es2015-arrow-functions"]
)
.bundle()
.pipe(outputJsFile)
outputJsFile.on('finish', -> console.log 'Done! Output to ./src/example/browser/cql4browsers.js')
task 'watch', 'Watch src/ and test/ for changes', ->
build('src', 'lib', true)
build('test', 'lib-test', true)
task 'watch-test-data', 'Watch test/data/cql-test-data.txt for changes', ->
buildTestData(true)
task "watch-all", "Watch src/, test/, and test/data/cql-test-data.txt for changes", ->
invoke 'watch'
invoke 'watch-test-data'
task "test", "run tests", ->
invoke 'build'
exec "NODE_ENV=test
./node_modules/.bin/nyc --reporter=html
./node_modules/.bin/mocha
--compilers coffee:coffeescript/register
--require coffeescript
--recursive
--colors
", {maxBuffer: 2048 * 1024 }, (err, output) ->
console.log output
throw err if err
task "debug-test", "run tests", ->
invoke 'build'
console.log 'To debug, you must install and launch node-inspector:'
console.log '1) $ npm install -g node-inspector'
console.log '2) $ node-inspector'
console.log '3) Visit http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858'
console.log '4) Subsequent tests may require you to reload the page in your browser'
exec "NODE_ENV=test
./node_modules/.bin/mocha
--recursive
--colors
--debug-brk
./lib-test/
", { maxBuffer: 2048 * 1024 }, (err, output) ->
console.log output
throw err if err