forked from mgechev/javascript-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (63 loc) · 1.94 KB
/
gulpfile.js
File metadata and controls
71 lines (63 loc) · 1.94 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
71
'use strict';
var gulp = require('gulp');
var shell = require('gulp-shell');
var jshint = require('gulp-jshint');
var jasmine = require('gulp-jasmine');
var istanbul = require('gulp-istanbul');
var reporters = require('jasmine-reporters');
var stylish = require('jshint-stylish');
var jshintXMLReporter = require('gulp-jshint-xml-file-reporter');
var jscs = require('gulp-jscs');
var jscs = require('gulp-jscs-custom');
var isWin = /^win/.test(process.platform);
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
gulp.task('jsdoc', shell.task([
(isWin) ?
'"node_modules/.bin/jsdoc.cmd" -c ./doc-config.json' :
'./node_modules/.bin/jsdoc -c ./doc-config.json'
]));
gulp.task('lint', ()=> {
return gulp.src(['./src/**/*.js'], ['./test/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(jshintXMLReporter))
.on('end', jshintXMLReporter.writeFile({
format: 'checkstyle',
filePath: './test/reports/jshint.xml',
alwaysReport: 'true'
}));
});
gulp.task('pre-test', ()=> {
return gulp.src(['./src/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', gulp.series(['pre-test'], ()=> {
return gulp.src('test/**/*.spec.js')
.pipe(jasmine({
reporter: new reporters.JUnitXmlReporter({
savePath: 'test/reports'
})
}))
.on("error", handleError)
// Creating the reports after tests ran
.pipe(istanbul.writeReports({
dir: './test/reports/coverage',
reporters: ['clover']
}));
}));
gulp.task('jscs', ()=> {
return gulp.src(['src/**/*.js', 'test/**/*.js'])
.pipe(jscs({
esnext: false,
configPath: '.jscsrc',
reporter: 'checkstyle',
filePath: './test/reports/jscs.xml',
failOnError: false
}));
});
gulp.task('build', gulp.parallel(['lint', 'jscs', 'test']));