-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.babel.js
60 lines (50 loc) · 1.53 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import del from 'del';
import eslint from 'gulp-eslint';
import babel from 'gulp-babel';
import sourcemaps from 'gulp-sourcemaps';
import mocha from 'gulp-mocha';
import istanbul from 'gulp-istanbul';
import remapIstanbul from 'remap-istanbul/lib/gulpRemapIstanbul';
gulp.task('clean', () => del(['lib/', 'test/', 'maps/', 'coverage/']));
gulp.task('lint', () =>
gulp.src(['src/**/*.js', 'gulpfile.babel.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
);
gulp.task('build', ['clean'], () =>
gulp.src('src/lib/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('../maps', { includeContent: false, sourceRoot: '../src/lib' }))
.pipe(gulp.dest('lib'))
);
gulp.task('build:test', ['build'], () =>
gulp.src('src/test/**/*.js')
.pipe(babel())
.pipe(gulp.dest('test'))
);
gulp.task('pre-test', ['build:test'], () =>
gulp.src(['lib/**/*.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire())
);
gulp.task('test', ['pre-test'], () =>
gulp.src(['test/**/*.js'])
.pipe(mocha({ timeout: 10000 }))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: { global: 50 } }))
);
gulp.task('remap-istanbul', ['test'], () =>
gulp.src('coverage/coverage-final.json')
.pipe(remapIstanbul({
basePath: 'maps/',
reports: {
json: 'coverage/coverage.json',
html: 'coverage/lcov-report',
lcovonly: 'coverage/lcov.info',
},
}))
);
gulp.task('default', ['lint', 'test']);