-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sakefile
103 lines (83 loc) · 2.62 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
use 'sake-bundle'
use 'sake-outdated'
use 'sake-publish'
use 'sake-version'
option '-b', '--browser [browserName]', 'Browser to test with'
option '-s', '--external-selenium', 'Use external selenium'
option '-v', '--verbose', 'Enable verbose logging for tests'
task 'build', 'Build module and bundle tractor_beam.js', ->
b = new Bundle
entry: 'src/index.coffee'
commonjs: true
compilers:
coffee:
version: 1
Promise.all [
# ES module (for bundlers)
b.write format: 'es'
# Node.js
b.write format: 'cjs'
# Browser (single file)
b.write
format: 'web'
sourceMap: false
]
task 'build:min', 'Build minified module', ['build'], ->
exec 'uglifyjs tractorbeam.js -o tractorbeam.min.js'
task 'watch', 'watch for changes and recompile', ->
exec 'bebop'
task 'static-server', 'Run static server for tests', ->
connect = require 'connect'
server = connect()
server.use (require 'serve-static') './test'
port = process.env.PORT ? 3333
console.log "Static server started at http://localhost:#{port}"
server.listen port
task 'selenium-install', 'Install selenium standalone', ->
exec 'node_modules/.bin/selenium-standalone install'
task 'test', 'Run tests', (options) ->
browserName = options.browser ? 'phantomjs'
externalSelenium = options.externalSelenium ? false
verbose = options.verbose ? false
invoke 'static-server'
runTest = (cb) ->
exec "NODE_ENV=test
BROWSER=#{browserName}
VERBOSE=#{verbose}
node_modules/.bin/mocha
--compilers coffee:coffee-script/register
--reporter spec
--colors
--timeout 90000
test/test.coffee", cb
if externalSelenium
runTest (err) ->
process.exit 1 if err?
process.exit 0
selenium = require 'selenium-standalone'
selenium.start (err, child) ->
throw err if err?
runTest (err) ->
child.kill()
process.exit 1 if err?
process.exit 0
task 'test:ci', 'Run tests on CI server', ->
invoke 'static-server'
browsers = require './test/ci-config'
tests = for {browserName, platform, version, deviceName, deviceOrientation} in browsers
"NODE_ENV=test
BROWSER=\"#{browserName}\"
PLATFORM=\"#{platform}\"
VERSION=\"#{version}\"
DEVICE_NAME=\"#{deviceName ? ''}\"
DEVICE_ORIENTATION=\"#{deviceOrientation ? ''}\"
VERBOSE=true
node_modules/.bin/mocha
--compilers coffee:coffee-script/register
--reporter spec
--colors
--timeout 60000
test/test.coffee"
exec tests, (err) ->
process.exit 1 if err?
process.exit 0