-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
78 lines (65 loc) · 1.87 KB
/
gulpfile.babel.js
File metadata and controls
78 lines (65 loc) · 1.87 KB
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
73
74
75
76
77
78
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 = {
lines: 100,
statements: 100,
functions: 100,
branches: 95
}
const { CIRCLECI, CIRCLE_TEST_REPORTS, COVERALLS } = process.env
const $ = loadPlugins()
const argv = yargs
.string('grep')
.boolean('bail')
.argv
const unitTest = () => gulp.src(['test/lib/setup.js', 'test/unit/**/*.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
}))
gulp.task('clean', () => del('lib'))
gulp.task('build', ['clean'], () => {
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('test:unit', unitTest)
gulp.task('coverage:instrument', () => {
return gulp.src('src/**/*.js')
.pipe($.istanbul({
instrumenter: Instrumenter
}))
.pipe($.istanbul.hookRequire())
})
gulp.task('coverage', ['coverage:instrument'], () => {
return unitTest()
.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('watch', () => gulp.watch('src/**/*', ['build']))
gulp.task('default', ['build'], () => gulp.start('watch'))