-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
72 lines (64 loc) · 1.53 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
/*eslint no-process-env: "off"*/
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const eslint = require('gulp-eslint');
const istanbul = require('gulp-istanbul');
const gulpIf = require('gulp-if');
const isFixed = (file) => {
// Has ESLint fixed the file contents?
return file.eslint != null && file.eslint.fixed;
};
gulp.task('test:dirty', () => {
return gulp.src('test.js')
.pipe(mocha({reporter: 'spec'}));
});
gulp.task('pre-test', () => {
return gulp.src([
'index.js',
'options.js'
])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('test:coverage', ['pre-test'], () => {
return gulp.src(['test.js'])
.pipe(mocha({reporter: 'spec'}))
.pipe(istanbul.writeReports({
reporters: [
'text',
'html',
'lcov'
]
}))
.pipe(istanbul.enforceThresholds({thresholds: {global: 70}}))
.once('error', () => {
console.error('coverage failed');
process.exit(1);
});
});
const lint = () => {
return gulp.src([
'**/*.js',
'!node_modules/**',
'!coverage/**'
])
.pipe(eslint({
fix: true
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.once('error', () => {
console.error('lint failed');
process.exit(1);
}).pipe(gulpIf(isFixed, gulp.dest('.')))
.once('end', () => {
process.exit();
});
};
gulp.task('test:lint', ['test:coverage'], () => {
return lint();
});
gulp.task('lint', () => {
return lint();
});
gulp.task('test', ['test:lint']);