-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
60 lines (49 loc) · 1.33 KB
/
gulpfile.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
require('babel-core/register');
const gulp = require('gulp');
const babel = require('gulp-babel');
const mocha = require('gulp-mocha');
const eslint = require('gulp-eslint');
const istanbul = require('gulp-istanbul');
const spawn = require('child_process').spawn;
function lint() {
return gulp
.src(['./gulpfile.js', './src/**/*.js', './test/**/*.js'])
.pipe(eslint({
'extends':'eslint:recommended'
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function hookIstanbul() {
return gulp
.src([ './src/**/*.js' ])
.pipe(istanbul({
instrumenter: require('babel-istanbul').Instrumenter
}))
.pipe(istanbul.hookRequire());
}
function test() {
return gulp
.src('test/**/*.js')
.pipe(mocha({reporter: 'spec'}))
.pipe(istanbul.writeReports({
reporters: ['lcovonly', 'text', 'text-summary', 'html']
}))
.pipe(istanbul.enforceThresholds({
thresholds: { global: 90 }
}));
}
function build() {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('dist'));
}
function publish(done) {
spawn('npm', ['publish'], { stdio: 'inherit' }).on('close', done);
}
gulp.task('lint', lint);
gulp.task('istanbul', hookIstanbul);
gulp.task('test', ['lint', 'istanbul'], test);
gulp.task('build', ['test'], build);
gulp.task('publish', ['build'], publish);