-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.babel.js
86 lines (75 loc) · 1.93 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import gulp from 'gulp'
const $ = require('gulp-load-plugins')()
const isparta = require('isparta') // doesn't work with import for some reason
import codecov from 'gulp-codecov.io'
import gulpJsdoc2md from 'gulp-jsdoc-to-markdown'
import { server as karma } from 'karma'
import del from 'del'
import path from 'path'
import manifest from './package.json'
const mainFile = manifest.main
const destinationFolder = path.dirname(mainFile)
gulp.task('clean', cb => {
del([destinationFolder], cb)
})
gulp.task('clean:cov', cb => {
del(['coverage'], cb)
})
// Build two versions of the library
gulp.task('build', ['clean'], () => (
gulp.src('src/**/*.js')
.pipe($.plumber())
.pipe($.sourcemaps.init({ loadMaps: true }))
.pipe($.babel({
stage: 0,
modules: 'umd',
}))
.pipe(gulp.dest('lib'))
))
gulp.task('istanbul', cb => {
gulp.src(['./src/**/*.js'])
.pipe($.istanbul({
instrumenter: isparta.Instrumenter,
includeUntested: true,
babel: { stage: 0 },
}))
.pipe($.istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', cb)
})
gulp.task('test', ['clean:cov', 'istanbul'], () => (
gulp.src('./test/**/*.js')
.pipe($.mocha({
reporter: 'spec',
}))
.pipe($.istanbul.writeReports({
dir: './coverage',
reportOpts: { dir: './coverage' },
reporters: ['lcovonly'],
}))
))
gulp.task('karma', done => {
karma.start({
configFile: `${__dirname}/karma.config.js`,
singleRun: true,
}, () => {
done()
})
})
gulp.task('coverage', () => (
gulp.src('./coverage/coverage.json')
.pipe(codecov())
))
gulp.task('docs', () => (
gulp.src('./src/**/*.js')
.pipe(gulpJsdoc2md())
.pipe($.rename(path => {
path.extname = '.md' // eslint-disable-line no-param-reassign
}))
.pipe(gulp.dest('docs'))
))
gulp.on('stop', () => {
process.nextTick(() => {
process.exit(0)
})
})
gulp.task('default', ['test'])