-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
64 lines (53 loc) · 1.45 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
let gulp = require('gulp')
let babel = require('gulp-babel')
let del = require('del')
let eslint = require('gulp-eslint')
let jest = require('@jacobq/gulp-jest').default
let srcFiles = ['src/**.js']
let srcTestFiles = ['test/*.js']
let jsFiles = ['gulpfile.js'].concat(srcFiles, srcTestFiles)
let jsonFiles = ['src/*.json']
let watchedFiles = jsFiles.concat(jsonFiles)
let testFiles = ['dist/test/*.js']
let dist = ['dist/**']
gulp.task('clean', () => {
return del(dist)
})
gulp.task('lint', () => {
return gulp
.src(jsFiles)
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulp.dest(file => file.base))
.pipe(eslint.failAfterError())
})
gulp.task('babel:srcFiles', () => {
return gulp
.src(srcFiles)
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(gulp.dest('dist'))
})
gulp.task('copy:Json', () => {
return gulp.src(jsonFiles).pipe(gulp.dest('dist'))
})
gulp.task('babel:srcTestFiles', () => {
return gulp
.src(srcTestFiles)
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(gulp.dest('dist/test'))
})
gulp.task('run:test', () => {
return gulp.src(testFiles).pipe(jest({}))
})
gulp.task(
'build',
gulp.series('clean', gulp.parallel('lint', 'babel:srcFiles', 'copy:Json'))
)
gulp.task(
'test',
gulp.series('clean', gulp.parallel('build', 'babel:srcTestFiles'), 'run:test')
)
gulp.task('watch', () => {
gulp.watch(watchedFiles, gulp.series('test'))
})
gulp.task('default', gulp.series('build', 'watch'))