forked from Zorium/zorium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.coffee
89 lines (77 loc) · 2.16 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
84
85
86
87
88
89
_defaults = require 'lodash/defaults'
del = require 'del'
gulp = require 'gulp'
mocha = require 'gulp-mocha'
karma = require('karma').server
rename = require 'gulp-rename'
webpack = require 'gulp-webpack'
coffeelint = require 'gulp-coffeelint'
RewirePlugin = require 'rewire-webpack'
webpackSource = require 'webpack'
packangeConf = require './package.json'
karmaConf =
frameworks: ['mocha']
client:
useIframe: true
captureConsole: true
mocha:
timeout: 300
files: [
'build/tests.js'
]
browsers: ['Chrome', 'Firefox']
paths =
coffee: ['./src/**/*.coffee', './*.coffee', './test/**/*.coffee']
tests: './test/**/*.coffee'
rootScripts: './src/zorium.coffee'
rootServerTests: './test/zorium_server.coffee'
build: './build/'
webpackProdConfig =
module:
exprContextRegExp: /$^/
exprContextCritical: false
loaders: [
{test: /\.coffee$/, loader: 'coffee'}
{test: /\.json$/, loader: 'json'}
]
resolve:
extensions: ['.coffee', '.js', '.json', '']
gulp.task 'test', ['scripts:test', 'lint', 'test:server'], (cb) ->
karma.start _defaults(singleRun: true, karmaConf), cb
gulp.task 'test:server', ->
gulp.src paths.rootServerTests
.pipe mocha()
gulp.task 'watch', ->
gulp.watch paths.coffee, ['test:phantom']
gulp.task 'watch:server', ->
gulp.watch paths.coffee, ['test:server']
gulp.task 'lint', ->
gulp.src paths.coffee
.pipe coffeelint()
.pipe coffeelint.reporter()
gulp.task 'test:phantom', ['scripts:test'], (cb) ->
karma.start _defaults({
singleRun: true,
browsers: ['PhantomJS']
}, karmaConf), cb
gulp.task 'scripts:test', ->
gulp.src paths.tests
.pipe webpack
devtool: '#inline-source-map'
module:
exprContextRegExp: /$^/
exprContextCritical: false
loaders: [
{test: /\.coffee$/, loader: 'coffee'}
{test: /\.json$/, loader: 'json'}
]
plugins: [
new RewirePlugin()
]
resolve:
extensions: ['.coffee', '.js', '.json', '']
modulesDirectories: ['node_modules', './src']
.pipe rename 'tests.js'
.pipe gulp.dest paths.build
gulp.task 'watch:test', ->
gulp.watch paths.scripts.concat([paths.tests]), ['test:phantom']