This repository was archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
70 lines (61 loc) · 1.78 KB
/
gulpfile.js
File metadata and controls
70 lines (61 loc) · 1.78 KB
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
"use strict";
let gulp = require('gulp-help')(require('gulp'));
let mocha = require('gulp-mocha');
let gutil = require('gulp-util');
let jshint = require('gulp-jshint');
let source = require('vinyl-source-stream');
let complexity = require('gulp-complexity');
let uglify = require('gulp-uglify');
let buffer = require('vinyl-buffer');
let istanbul = require('gulp-istanbul');
let allSrcFiles = [
'./lib/**/*.js'
];
let allSrc = gulp.src(allSrcFiles);
let allSrcInclTests = gulp.src(Array.from(new Set(allSrcFiles, ['./test/**/*.js'])));
gulp.task('default', ['help']);
gulp.task('hint',
'Runs the JSLinter on your code.',
function() {
return allSrcInclTests
.pipe(jshint({
node: true,
esnext: true
})).pipe(jshint.reporter('default'));
}
);
gulp.task('complexity',
'Runs cyclometric complexity tests on your code.',
function() {
return allSrc
.pipe(complexity({breakOnErrors: false}));
}
);
gulp.task('test',
'Runs the unit tests and calculates code coverage',
function(next) {
allSrc
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function(){
gulp.src(['test/unit/**/*_test.js'], { read: false })
.pipe(mocha({ reporter: 'spec' }))
.on('error', gutil.log)
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: { global: 85 } }))
.on('end', next);
});
}
);
gulp.task('qa',
'Runs JSLinter, Complexity analysis, and the tests with code coverage',
['hint', 'complexity', 'test']
);
gulp.task('qt',
'Runs the unit tests without coverage and with the fail-fast option turned on.',
function() {
return gulp.src(['test/unit/**/*_test.js'], { read: false })
.pipe(mocha({ reporter: 'spec', bail: true }))
.on('error', gutil.log);
}
);