-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.babel.js
73 lines (63 loc) · 1.77 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
import gulp from 'gulp';
import babel from 'gulp-babel';
import mocha from 'gulp-mocha';
import eslint from 'gulp-eslint';
import rimraf from 'gulp-rimraf';
import runSequence from 'run-sequence';
var config = {
paths: {
js: {
src: 'src/**/*.js',
dist: 'dist/'
},
test: {
src: 'test/**/*.js',
dist: 'test-dist/',
run: 'test-dist/**/*.js'
}
}
};
gulp.task('clean', () =>
gulp.src([config.paths.js.dist, config.paths.test.dist])
.pipe(rimraf({ force: true }))
);
gulp.task('babel', ['babel-src', 'babel-test']);
gulp.task('babel-src', ['lint-src'], () =>
gulp.src(config.paths.js.src)
.pipe(babel())
.pipe(gulp.dest(config.paths.js.dist))
);
gulp.task('babel-test', ['lint-test'], () =>
gulp.src(config.paths.test.src)
.pipe(babel())
.pipe(gulp.dest(config.paths.test.dist))
);
gulp.task('lint-src', () =>
gulp.src(config.paths.js.src)
.pipe(eslint())
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError())
);
gulp.task('lint-test', () =>
gulp.src(config.paths.test.src)
.pipe(eslint())
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError())
);
gulp.task('watch', () => {
gulp.watch(config.paths.js.src, ['babel-src', 'test']);
gulp.watch(config.paths.test.src, ['babel-test', 'test']);
});
gulp.task('test', ['babel'], () =>
gulp.src([config.paths.test.run])
.pipe(mocha({ reporter: 'spec' }))
.on('error', err => console.log(err.stack))
);
// Default Task
gulp.task('default', () =>
runSequence('clean', ['babel', 'test'])
);