-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
50 lines (44 loc) · 1.09 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
var gulp = require('gulp');
var args = require('yargs').argv;
var sequence = require('run-sequence');
var $ = require('gulp-load-plugins')({lazy: true});
gulp.task('build', ['build-test'], function() {
return gulp.src(['./src/**/*.js', '!./src/**/*.spec.js'])
.pipe($.babel({
presets: ['es2015']
}))
.pipe(gulp.dest('lib'));
});
gulp.task('build-test', function() {
return gulp.src('./src/**/*.spec.js')
.pipe($.babel({
presets: ['es2015']
}))
.pipe(gulp.dest('test'));
});
gulp.task('test', function(done) {
if (args.coverage) {
sequence('pre-tests', 'run-tests', done);
} else {
sequence('run-tests', done);
}
});
gulp.task('pre-tests', function() {
return gulp.src('./lib/**/*.js')
.pipe($.istanbul({
includeUntested: true
}))
.pipe($.istanbul.hookRequire());
});
gulp.task('run-tests', function() {
var stream = gulp.src('./test/*.spec.js', {read: false})
.pipe($.mocha());
if (args.coverage) {
stream.pipe($.istanbul.writeReports({
reportOpts: {
dir: './coverage'
}
}));
}
return stream;
});