-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
54 lines (42 loc) · 1.46 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
import gulp from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import { Instrumenter } from 'isparta'
import del from 'del'
import seq from 'run-sequence'
const COVERAGE_THRESHOLDS = { global: 90 }
const $ = loadPlugins()
gulp.task('clean', () => del('lib'))
gulp.task('transpile', () => {
return gulp.src('src/**/*.js')
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('lib'))
})
gulp.task('lint', () => {
return gulp.src('{src,test}/**/*.js')
.pipe($.standard())
.pipe($.standard.reporter('default', { breakOnError: false }))
})
gulp.task('pre-coverage', () => {
return gulp.src('src/**/*.js')
.pipe($.istanbul({ instrumenter: Instrumenter }))
.pipe($.istanbul.hookRequire())
})
gulp.task('coverage', ['pre-coverage'], () => {
return gulp.src(['test/lib/setup.js', 'test/{unit,integration}/**/*.js', '!**/_*.js'], { read: false })
.pipe($.mocha({ reporter: 'spec' }))
.pipe($.istanbul.writeReports())
.pipe($.istanbul.enforceThresholds({ thresholds: COVERAGE_THRESHOLDS }))
})
gulp.task('coveralls', () => {
if (!process.env.COVERALLS) {
return
}
return gulp.src('coverage/lcov.info')
.pipe($.coveralls())
})
gulp.task('test', (cb) => seq('lint', 'coverage', 'coveralls', cb))
gulp.task('build', (cb) => seq('test', 'clean', 'transpile', cb))
gulp.task('watch', () => gulp.watch('{src,test}/**/*', ['build']))
gulp.task('default', ['build'], () => gulp.start('watch'))