-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.babel.js
98 lines (83 loc) · 2.2 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
'use strict';
import gulp from 'gulp';
import babel from 'gulp-babel';
import rimraf from 'rimraf';
import istanbul from 'gulp-istanbul';
import mocha from 'gulp-mocha';
import jscs from 'gulp-jscs';
import stylish from 'gulp-jscs-stylish';
import jshint from 'gulp-jshint';
import coveralls from 'gulp-coveralls';
const isparta = require('isparta');
let watching = false;
function onError(err) {
console.log(err.toString());
if (watching) {
this.emit('end');
} else {
process.exit(1);
}
}
gulp.task('clean', (done) => {
rimraf.sync('server');
done();
});
gulp.task('jshint', [ 'clean' ], () => {
return gulp.src('./src/**/*.js')
.pipe(jshint({'esnext':true,'node':true}))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', [ 'jshint' ], () => {
return gulp.src('./src/**/*.js')
.pipe(jscs({esnext:true}))
.pipe(stylish())
.pipe(jscs.reporter('fail'));
});
gulp.task('babel', [ 'jscs' ], () => {
return gulp.src('./src/**/*.js')
.pipe(babel({
presets: ['es2016-node5']
}))
.pipe(gulp.dest('lib'));
});
gulp.task('build', [ 'babel' ]);
gulp.task('instrument', [ 'build' ], () => {
return gulp.src([ './src/**/*.js' ])
.pipe(istanbul({
instrumenter: isparta.Instrumenter,
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});
gulp.task('unitTest', [ 'instrument' ], () => {
let mochaOpts = {
reporter: 'spec',
bail: !watching
};
let thresholds = {
thresholds: {
global: 90
}
}
return gulp.src([ './test/unit/**/*.js' ], {read: false})
.pipe(mocha(mochaOpts))
.on('error', onError)
.pipe(istanbul.writeReports({dir:'./coverage/unit'}))
.pipe(istanbul.enforceThresholds(thresholds));
});
gulp.task('functionalTest', [ 'unitTest' ], () => {
let mochaOpts = {
reporter: 'spec',
bail: !watching
};
return gulp.src([ './test/functional/**/*.js' ], {read: false})
.pipe(mocha(mochaOpts))
.on('error', onError);
});
gulp.task('coveralls', [ 'functionalTest' ], () => {
return gulp.src('./coverage/unit/lcov.info')
.pipe(coveralls());
});
gulp.task('travisTest', [ 'coveralls' ]);
gulp.task('default', [ 'functionalTest' ]);