-
Notifications
You must be signed in to change notification settings - Fork 50
/
gulpfile.babel.js
51 lines (44 loc) · 1.27 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
'use strict';
import babel from 'gulp-babel';
import babelCompiler from 'babel-core';
import del from 'del';
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import istanbul from 'gulp-istanbul';
import mocha from 'gulp-mocha';
const configFiles = 'gulpfile.babel.js'
, destDir = 'generators/'
, srcFiles = 'lib/*/*.js'
, testFiles = 'test/*.js';
gulp.task('clean', () => del(destDir));
gulp.task('lint', () =>
gulp.src([configFiles, srcFiles, testFiles])
.pipe(eslint())
.pipe(eslint.format('node_modules/eslint-formatter-pretty'))
.pipe(eslint.failAfterError())
);
gulp.task('compile', ['clean', 'lint'], () =>
gulp.src(srcFiles, {base: './lib'})
.pipe(babel())
.pipe(gulp.dest(destDir))
);
gulp.task('copy:templates', ['clean'], () =>
gulp.src(['lib/*/templates/**/*', 'lib/*/templates/.*'])
.pipe(gulp.dest(destDir))
);
gulp.task('build', ['compile', 'copy:templates']);
gulp.task('test', ['build'], cb => {
gulp.src([destDir + '*/*.js', '!' + testFiles])
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', () => {
gulp.src([testFiles])
.pipe(mocha({
compilers: {
js: babelCompiler
}
}))
.pipe(istanbul.writeReports())
.on('end', cb);
});
});