-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
65 lines (51 loc) · 1.56 KB
/
gulpfile.babel.js
File metadata and controls
65 lines (51 loc) · 1.56 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
import gulp from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import {Instrumenter} from 'isparta'
import del from 'del'
import mkdirp from 'mkdirp'
import seq from 'run-sequence'
const DEST = 'lib'
const $ = loadPlugins()
const plumb = () => $.plumber({
errorHandler: $.notify.onError('<%= error.message %>')
})
const test = () => {
return gulp.src(['test/lib/setup.js', 'test/unit/**/*.js'], {read: false})
.pipe(plumb())
.pipe($.mocha({reporter: 'dot'}))
}
gulp.task('clean', () => del.sync(DEST))
gulp.task('transpile', () => {
mkdirp.sync(DEST)
return gulp.src('src/**/*.js')
.pipe(plumb())
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest(DEST))
})
gulp.task('lint', () => {
return gulp.src('src/**/*.js')
.pipe(plumb())
.pipe($.standard())
.pipe($.standard.reporter('default', {
breakOnError: false
}))
})
gulp.task('build', (cb) => seq('lint', 'test', 'transpile', cb))
gulp.task('cleanbuild', (cb) => seq('clean', 'build', cb))
gulp.task('coverage', (cb) => {
gulp.src('src/**/*.js')
.pipe(plumb())
.pipe($.istanbul({instrumenter: Instrumenter}))
.pipe($.istanbul.hookRequire())
.on('finish', () => test().pipe($.istanbul.writeReports()).on('end', cb))
})
gulp.task('coveralls', ['coverage'], () => {
return gulp.src('coverage/lcov.info')
.pipe(plumb())
.pipe($.coveralls())
})
gulp.task('test', test)
gulp.task('watch', () => gulp.watch('{src,test}/**/*', ['cleanbuild']))
gulp.task('default', ['cleanbuild'], () => gulp.start('watch'))