-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSakefile
104 lines (83 loc) · 2.66 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
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'
option '-l', '--local', 'use local server for testing'
task 'clean', 'clean project', ->
exec 'rm -rf lib'
task 'build', 'build project', ->
b = new Bundle
compilers:
coffee:
version: 1
Promise.all [
b.write
entry: 'src/browser.coffee'
external: false
format: 'web'
sourceMap: 'inline'
# Build es lib for bundlers
b.write
entry: 'src/browser.coffee'
format: 'es'
# Build commonjs lib
b.write
entry: 'src/node.coffee'
format: 'cjs'
include: ['es-is']
]
task 'build:min', 'build project and minify', ['build'], ->
exec 'uglifyjs hanzo.js -o hanzo.min.js'
server = do require 'connect'
task 'server', 'Run static server for tests', (cb) ->
port = process.env.PORT ? 3333
server.use (require 'serve-static') './test/fixtures'
server = require('http').createServer(server).listen port, cb
task 'test', 'Run tests', ['build', 'server'], (opts) ->
bail = opts.bail ? true
coverage = opts.coverage ? false
grep = opts.grep ? ''
test = opts.test ? '"test/**/*.coffee"'
verbose = opts.verbose ? ''
endpoint = opts.endpoint ? ''
bail = '--bail' if bail
grep = "--grep #{opts.grep}" if grep
verbose = 'DEBUG=nightmare VERBOSE=true HANZO_DEBUG=1' if verbose
if coverage
bin = 'istanbul --print=none cover _mocha --'
else
bin = 'mocha'
{status} = yield exec.interactive "NODE_ENV=test HANZO_KEY='' HANZO_ENDPOINT='' #{verbose}
#{bin}
--colors
--reporter spec
--timeout 10000000
--require coffeescript/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 'coverage', 'Process coverage statistics', ->
exec '''
cat ./coverage/lcov.info | coveralls
cat ./coverage/coverage.json | codecov
rm -rf coverage/
'''
task 'watch', 'watch for changes and recompile project', ->
exec 'coffee -bcmw -o lib/ src/'
task 'watch:test', 'watch for changes and re-run tests', ->
invoke 'watch'
require('vigil').watch __dirname, (filename, stats) ->
if /^src/.test filename
invoke 'test'
if /^test/.test filename
invoke 'test', test: filename