-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (68 loc) · 1.75 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Task runnning via Gulp
*
*/
'use strict';
// Dependencies
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var $ = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
var exit = require('gulp-exit');
var istanbul = require('gulp-istanbul');
// Build defaults
gulp.task('default', function (callback) {
console.log('Please specify a gulp task');
});
// Run all tests
gulp.task('test', function(callback){
runSequence(
'lint',
'test:coverage',
'test:unit',
'test:kill',
callback);
});
// Lint the codebase (but not the node_modules)
gulp.task('lint', function () {
return gulp.src(['*.js','lib/**.js', 'test/**.js'])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
});
// Run unit tests
gulp.task('test:unit', function () {
return gulp.src(['test/**/*.js', '!test/**/_*.js'], {read: false})
.pipe(mocha({
reporter: 'spec',
ui : 'bdd'
}).on('error', process.exit.bind(process, 1)))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: {
global: {
statements: 90,
branches: 90,
lines: 90,
functions: 90
},
each: {
statements: 90,
branches: 90,
lines: 90,
functions: 90
}
}
}).on('error', process.exit.bind(process, 1)));
});
// Run code coverage
gulp.task('test:coverage', function(){
return gulp.src(['index.js', 'lib/**/*.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
// Kill the test process by piping to exit
gulp.task('test:kill', function () {
return gulp.src(['index.js'], {read: false})
.pipe(exit());
});