-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgulpfile.babel.js
67 lines (55 loc) · 1.81 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
61
62
63
64
65
66
67
import gulp from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import {Instrumenter} from 'isparta'
import del from 'del'
import seq from 'run-sequence'
import yargs from 'yargs'
const COVERAGE_THRESHOLDS = {global: 90}
const {CIRCLECI, CIRCLE_TEST_REPORTS, COVERALLS} = process.env
const $ = loadPlugins()
const argv = yargs
.string('grep')
.boolean('bail')
.argv
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: CIRCLECI ? 'mocha-junit-reporter' : 'spec',
reporterOptions: CIRCLECI ? {
mochaFile: `${CIRCLE_TEST_REPORTS}/junit/test-results-${process.version}.xml`
} : {},
grep: argv.grep,
bail: argv.bail
}))
.pipe($.istanbul.writeReports())
.pipe($.istanbul.enforceThresholds({thresholds: COVERAGE_THRESHOLDS}))
})
gulp.task('coveralls', () => {
if (!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'))