1 | import gulp from 'gulp';
|
2 | import babel from 'gulp-babel';
|
3 | import replace from 'gulp-replace';
|
4 | import mocha from 'gulp-mocha';
|
5 |
|
6 | const files = {
|
7 | src : 'src/**/*.js',
|
8 | test: 'test/**/*.js',
|
9 | };
|
10 |
|
11 | gulp.task('watch', () => {
|
12 | return gulp.watch(files.src, ['babel']);
|
13 | });
|
14 |
|
15 | gulp.task('babel', () => {
|
16 | return gulp.src(files.src)
|
17 | .pipe(babel())
|
18 | .pipe(replace(/\n{2,}/g, '\n'))
|
19 | .pipe(gulp.dest('lib'))
|
20 | .on('end', () => {
|
21 | gulp.start('mocha');
|
22 | });
|
23 | });
|
24 |
|
25 | gulp.task('mocha', () => {
|
26 | return gulp.src(files.test, { read: false })
|
27 | .pipe(babel())
|
28 | .pipe(mocha({ reporter: 'tap' }))
|
29 | });
|
30 |
|
31 | gulp.task('default', [
|
32 | 'watch',
|
33 | 'babel',
|
34 | ]);
|