-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
58 lines (49 loc) · 1.47 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
import del from 'del';
import path from 'path';
import * as isparta from 'isparta';
import gulp from 'gulp';
import plugins from 'gulp-load-plugins';
const $ = plugins();
const paths = {
lint: ['./gulpfile.babel.js', './lib/**/*.js', './test/**/*.js'],
watch: ['./gulpfile.babel.js', './lib/**', './test/**/*.js'],
tests: ['./test/**/*.js'],
};
gulp.task('lint', () => {
return gulp.src(paths.lint)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('nsp', function(cb) {
$.nsp({package: path.resolve('package.json')}, cb);
});
gulp.task('pre-test', () => {
return gulp.src(['lib/**/*.js'], {cwd: __dirname})
// Covering files
.pipe($.istanbul(
// supports es6
{instrumenter: isparta.Instrumenter}))
// Force `require` to return covered files
.pipe($.istanbul.hookRequire());
});
gulp.task('test', gulp.series('pre-test', () => {
return gulp.src(paths.tests, {cwd: __dirname})
.pipe($.mocha())
// Creating the reports after tests ran
.pipe($.istanbul.writeReports());
}));
gulp.task('coveralls', () => {
return gulp.src('coverage/lcov.info')
.pipe($.coveralls());
});
gulp.task('clean', () => {
return del('dist');
});
gulp.task('babel', gulp.series(['clean'], () => {
return gulp.src('lib/**/*.js')
.pipe($.babel())
.pipe(gulp.dest('dist'));
}));
gulp.task('prepublish', gulp.series(['nsp', 'babel']));
gulp.task('default', gulp.series(['test', 'lint', 'coveralls']));