-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
80 lines (64 loc) · 1.7 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
80
'use strict';
/* eslint no-process-exit:0 */
// load third party modules
const del = require( 'del' );
const gulp = require( 'gulp' );
const mocha = require( 'gulp-mocha' );
const istanbul = require( 'gulp-istanbul' );
const covEnforcerOpts = {
'thresholds' : require( 'sinet-istanbul-coverage-enforcement' )
};
const paths = {
'cover' : [
// Include everything to be covered
'**/*.js',
// Exclude files
'!gulpfile.js',
// Exclude directories that are not code
'!instrumented/**',
'!node_modules/**',
'!test/**'
],
'test' : [ 'test/**/*.js' ],
'coverage' : 'instrumented'
};
gulp.task( 'clean-coverage', function () {
del( [ 'instrumented' ] );
} );
gulp.task( 'test', [ 'clean-coverage' ], function () {
let coverageDir = paths.coverage;
let mochaOptions = {
'ui' : 'bdd',
'reporter' : 'spec',
'bail' : true,
'timeout' : 5000
};
return gulp.src( paths.cover )
.pipe( istanbul( { 'includeUntested' : true } ) )
.pipe( istanbul.hookRequire() )
.on( 'finish', function () {
gulp.src( paths.test, { 'read' : false } )
.pipe(
mocha( mochaOptions )
.on( 'error', function () {
process.exit( 1 );
}
) )
.pipe( istanbul.writeReports( {
'dir' : coverageDir,
'reportOpts' : { 'dir' : coverageDir },
'reporters' : [ 'text', 'text-summary', 'json', 'html' ]
} ) )
.pipe( istanbul.enforceThresholds( covEnforcerOpts )
.on( 'error', function () {
console.log( 'error - coverage enforcer' );
process.exit( 1 );
} ) )
.on( 'error', function () {
process.exit( 1 );
} )
.on( 'end', function () {
process.exit();
} );
} );
} );