-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (52 loc) · 1.43 KB
/
gulpfile.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
'use strict';
var gulp = require('gulp'),
istanbul = require('gulp-istanbul'),
mocha = require('gulp-mocha'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish');
var paths = {
js: ['gulpfile.js', 'lib/**/*.js'],
test: ['test/**/*.js']
};
gulp.task('mocha', function () {
return gulp.src(paths.test)
.pipe(mocha());
});
gulp.task('coverage', function (done) {
return gulp.src(paths.js)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(paths.test)
.pipe(mocha())
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {
// INCREASE TO 100% ON COMPLETION
global: {
statements: 95,
branches: 95,
lines: 95,
functions: 95
},
each: {
statements: 95,
branches: 95,
lines: 95
}
}
}))
.on('end', done);
});
});
gulp.task('lint', function() {
return gulp.src(Array.prototype.concat.call([], paths.js, paths.test))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('watch-test', function () {
gulp.watch(Array.prototype.concat.apply([], [paths.js, paths.test]), ['lint', 'mocha']);
});
gulp.task('test', ['lint', 'mocha']);
gulp.task('default', ['watch-test']);