-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathSakefile
110 lines (90 loc) · 2.81 KB
/
Sakefile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use 'sake-bundle'
use 'sake-outdated'
use 'sake-publish'
use 'sake-version'
option '-b', '--browser [browser]', 'browser to use for tests'
option '-g', '--grep [filter]', 'test filter'
option '-t', '--test [test]', 'specify test to run'
option '-v', '--verbose', 'enable verbose test logging'
task 'clean', 'clean project', ->
exec 'rm -rf lib'
task 'build', 'build js', ['build:static'], ->
bundle.write
entry: 'src/index.coffee'
compilers:
coffee:
version: 1
task 'build:min', 'build js for production', ['build'], ->
yield bundle.write
entry: 'src/index.coffee'
format: 'web'
external: false
sourceMap: false
browser: false
compilers:
coffee:
version: 1
yield exec 'uglifyjs el.js -o el.min.js'
task 'build:static', 'build static assets', ->
exec '''
bebop compile'
'''
task 'test', 'Run tests', ['build', 'static-server'], (opts) ->
bail = opts.bail ? true
coverage = opts.coverage ? false
grep = opts.grep ? ''
test = opts.test ? 'test/'
verbose = opts.verbose ? ''
bail = '--bail' if bail
grep = "--grep #{opts.grep}" if grep
verbose = 'DEBUG=nightmare VERBOSE=true CROWDSTART_DEBUG=1' if verbose
if coverage
bin = 'istanbul --print=none cover _mocha --'
else
bin = 'mocha'
{status} = yield exec.interactive "NODE_ENV=test CROWDSTART_KEY='' CROWDSTART_ENDPOINT='' #{verbose}
#{bin}
--colors
--reporter spec
--timeout 10000000
--compilers coffee:coffee-script/register
--require co-mocha
--require postmortem/register
#{bail}
#{grep}
#{test}"
server.close()
process.exit status
task 'test:ci', 'Run tests', (opts) ->
invoke 'test',
bail: true
coverage: true
task 'test:coverage', 'Process coverage statistics', ->
exec '''
cat ./coverage/lcov.info | coveralls
cat ./coverage/coverage.json | codecov
rm -rf coverage/
'''
task 'example', 'Launch Examples', ->
exec 'coffee examples/server.coffee'
exec 'cake watch'
task 'server', 'Run static server for tests', do ->
server = do require 'connect'
(cb) ->
port = process.env.PORT ? 3333
server.use (require 'serve-static') './test/fixtures'
server = require('http').createServer(server).listen port, cb
task 'watch', 'watch for changes and recompile project', ->
build = (filename) ->
return if (running 'build')
console.log filename, 'modified'
invoke 'build'
watch 'src/*', build
watch 'node_modules/*', build
task 'watch:test', 'watch for changes and re-run tests', ->
test = ->
return if (running 'build') or (running 'test')
console.log filename, 'modified'
invoke 'build', -> invoke 'test'
watch 'src/*', test
watch 'node_modules/*', test