-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
118 lines (108 loc) · 2.83 KB
/
gulpfile.babel.js
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
111
112
113
114
115
116
117
118
import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
const plugins = gulpLoadPlugins();
gulp.task('lint', () => gulp.src(
[
'gulpfile.babel.js',
'./config/**/*.js',
'.app/**/*.js'
]
)
.pipe(plugins.jshint())
.pipe(plugins.livereload()));
gulp.task('transpile', ['public'], () => {
gulp.src(
[
'./**/*.js',
'!dist/**',
'!node_modules/**',
'!bower_components/**',
'!public/lib/**'
]
)
.pipe(plugins.babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('serve', ['public'], () => {
plugins.nodemon({
watch: ['./dist', './app', './config', './public'],
script: 'dist/server.js',
ext: 'js html jade',
env: { NODE_ENV: 'development' }
});
});
gulp.task('sass', () => gulp.src('./public/**/*.scss')
.pipe(plugins.sass().on('error', plugins.sass.logError))
.pipe(gulp.dest('./dist/css'))
.pipe(plugins.livereload()));
gulp.task('jasmine', () => {
gulp.src('./test/**/*.js')
.pipe(plugins.jasmine());
});
gulp.task('test', () => gulp.src(
[
'./dist/test/game/game.js',
'./dist/test/user/model.js'
],
{ read: false }
)
.pipe(plugins.coverage.instrument({
pattern: ['**/test*'],
debugDirectory: 'debug'
}))
.pipe(plugins.mocha({
timeout: 15000
}))
.pipe(plugins.coverage.gather())
.pipe(plugins.coverage.format())
.pipe(gulp.dest('reports')));
gulp.task('watch', () => {
plugins.livereload.listen();
gulp.watch('./public/**/*.scss', ['sass', 'transpile']);
gulp.watch('./public/**/*.html', ['sass', 'transpile']);
gulp.watch('./public/**/*.css', ['sass', 'transpile']);
gulp.watch('./public/**/*.js', ['sass', 'transpile']);
});
gulp.task('coveralls', ['test'], () => gulp.src('coverage/lcov.info')
.pipe(plugins.coveralls())
.pipe(plugins.exit()));
gulp.task('public', () => gulp.src([
'./public/**/*',
'./app/**/*',
'./config/**/*',
'./css/**/*',
'test/**/*'
], {
base: './'
})
.pipe(gulp.dest('dist')));
gulp.task('coverage', (cb) => {
gulp.src(['app/**/*.js', 'config/**/*.js'])
.pipe(plugins.babel())
.pipe(plugins.istanbul())
.pipe(plugins.istanbul.hookRequire())
.on('finish', () => {
gulp.src(
[
('./test/**/*.js')
]
)
.pipe(plugins.babel())
.pipe(plugins.injectModules())
.pipe(plugins.jasmine())
// .pipe(plugins.istanbul.writeReports())
.pipe(plugins.istanbul.enforceThresholds({
thresholds: { global: 20 } }))
.on('end', cb);
});
});
gulp.task('coveralls', ['coverage'], () => gulp.src('coverage/lcov.info')
.pipe(plugins.coveralls())
.pipe(plugins.exit()));
gulp.task('bower', () => {
plugins.bower({ directory: './bower_components' })
.pipe(gulp.dest('./public/lib'));
});
gulp.task('default', ['bower', 'transpile', 'serve', 'watch']);