forked from Zorium/location-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.coffee
83 lines (72 loc) · 2.13 KB
/
Gulpfile.coffee
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
_ = require 'lodash'
gulp = require 'gulp'
mocha = require 'gulp-mocha'
KarmaServer = require('karma').Server
rename = require 'gulp-rename'
webpack = require 'webpack-stream'
istanbul = require 'gulp-coffee-istanbul'
coffeelint = require 'gulp-coffeelint'
TEST_TIMEOUT = 300
paths =
coffee: ['./src/**/*.coffee', './*.coffee', './test/**/*.coffee']
cover: ['./src/**/*.coffee', './*.coffee']
rootScripts: './src/index.coffee'
rootTests: './test/**/*.coffee'
build: './build'
output:
tests: 'tests.js'
karmaConf =
frameworks: ['mocha']
client:
useIframe: true
captureConsole: true
mocha:
timeout: TEST_TIMEOUT
files: [
"#{paths.build}/#{paths.output.tests}"
]
browsers: ['Chrome', 'Firefox']
gulp.task 'test', ['lint', 'test:browser', 'test:coverage']
gulp.task 'watch', ->
gulp.watch paths.coffee, ['test:node']
gulp.task 'watch:phantom', ->
gulp.watch paths.coffee, ['test:browser:phantom']
gulp.task 'lint', ->
gulp.src paths.coffee
.pipe coffeelint()
.pipe coffeelint.reporter()
gulp.task 'test:browser', ['build:test'], (cb) ->
new KarmaServer(_.defaults(singleRun: true, karmaConf), cb).start()
gulp.task 'test:browser:phantom', ['build:test'], (cb) ->
new KarmaServer(_.defaults({
singleRun: true,
browsers: ['PhantomJS']
}, karmaConf), cb).start()
gulp.task 'test:node', ->
gulp.src paths.rootTests
.pipe mocha({timeout: TEST_TIMEOUT})
gulp.task 'test:coverage', ->
gulp.src paths.cover
.pipe istanbul includeUntested: false
.pipe istanbul.hookRequire()
.on 'finish', ->
gulp.src paths.rootTests
.pipe mocha({timeout: TEST_TIMEOUT})
.pipe istanbul.writeReports({
reporters: ['html', 'text', 'text-summary']
})
gulp.task 'build:test', ->
gulp.src paths.rootTests
.pipe webpack
devtool: 'inline-source-map'
module:
exprContextRegExp: /$^/
exprContextCritical: false
loaders: [
{test: /\.coffee$/, loader: 'coffee'}
{test: /\.json$/, loader: 'json'}
]
resolve:
extensions: ['.coffee', '.js', '.json', '']
.pipe rename paths.output.tests
.pipe gulp.dest paths.build