-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
84 lines (76 loc) · 2.24 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
81
82
83
84
/*eslint strict:0*/
'use strict';
const path = require('path');
const gulp = require('gulp');
const {
series
} = gulp;
const fs = require('fs');
const rimraf = require('rimraf');
const watch = require('gulp-watch');
const debug = require('gulp-debug');
const batch = require('gulp-batch');
const eslint = require('gulp-eslint');
const excludeGitignore = require('gulp-exclude-gitignore');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');
const plumber = require('gulp-plumber');
const taskWatchTest = function () {
watch(['generators/**/*.js', 'utils/*.js', 'test/**/*.js'], batch(function (events, done) {
gulp.start('test', done);
}));
};
const taskCheckstyle = function () {
const targetFolder = 'target';
if (fs.existsSync(targetFolder)) {
rimraf.sync(targetFolder);
}
fs.mkdirSync('target');
return gulp.src(['generators/**/*.js', 'utils/*.js', 'test/**/*.js'])
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format('checkstyle', fs.createWriteStream(path.join(targetFolder, '/checkstyle-result.xml'))));
};
//requires checkstyle
const taskLint = function () {
return gulp.src(['generators/**/*.js', 'utils/*.js', 'test/**/*.js'])
.pipe(excludeGitignore())
.pipe(eslint({
fix: true
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
};
const taskPreTest = function () {
return gulp.src(['generators/**/*.js', 'utils/*.js'])
.pipe(debug())
.pipe(istanbul({
includeUntested: false
}))
.pipe(istanbul.hookRequire());
};
// requires pre-test
const taskTest = function () {
return gulp.src('test/**/*.js')
.pipe(debug())
.pipe(plumber())
.pipe(mocha({
// grep: 'Synchronization Lib Modules',
reporter: 'spec'
}))
.once('error', () => {
process.exit(1);
})
.pipe(istanbul.writeReports({
reporters: ['lcov', 'json', 'text', 'text-summary', 'cobertura']
}));
};
module.exports = {
'watch-test': taskWatchTest,
checkstyle: taskCheckstyle,
lint: series(taskCheckstyle, taskLint),
'pre-test': taskPreTest,
test: series(taskPreTest, taskTest),
prepublish: series(taskCheckstyle, taskLint, taskPreTest, taskTest),
default: series(taskCheckstyle, taskLint, taskPreTest, taskTest),
};