-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
61 lines (51 loc) · 1.37 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
import gulp from 'gulp';
import babel from 'gulp-babel';
import del from 'del';
import jasmine from 'gulp-jasmine';
import istanbul from 'gulp-istanbul';
import reqDir from 'require-dir';
import {
build as config
} from './package.json';
import {
Instrumenter as isparta
} from 'isparta';
gulp.task('clean', () => {
return del([config.paths.dist, config.paths.coverage], { force: true });
});
function test() {
return gulp.src(`${config.paths.spec}/**/*.js`)
.pipe(jasmine());
}
gulp.task(test);
gulp.task('compile', () => {
return gulp.src(`${config.paths.src}/**/*.js`)
.pipe(babel())
.pipe(gulp.dest(config.paths.dist));
});
gulp.task('build', gulp.series('clean', 'test', 'compile'));
gulp.task('default', gulp.task('build'));
gulp.task('watch', () => {
return gulp.watch([config.paths.src, config.paths.spec], gulp.task('build'));
});
const coverage = {
setup() {
return gulp.src(`${config.paths.src}/**/*.js`)
.pipe(istanbul({
instrumenter: isparta,
includeUntested: true
}))
.pipe(istanbul.hookRequire());
},
run() {
return test()
.pipe(istanbul.writeReports({
reporters: ['lcov', 'text'],
reportOpts: { dir: config.paths.coverage }
}));
}
};
gulp.task('coverage', gulp.series(coverage.setup, coverage.run));
try {
reqDir(config.paths.build);
} catch(err) {}