forked from pie-framework/pie-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (41 loc) · 1.55 KB
/
gulpfile.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
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
ts = require('gulp-typescript'),
tsProject = ts.createProject('tsconfig.json'),
fsExtra = require('fs-extra'),
runSequence = require('run-sequence'),
path = require('path'),
spawn = require('child_process').spawn,
{ join } = require('path');
let glue = suffix => gulp.src(`src/**/*.${suffix}`).pipe(gulp.dest('lib'));
let watch = (suffix, tasks) => {
tasks = tasks ? tasks : [suffix];
return gulp.watch(`src/**/*.${suffix}`, tasks);
}
gulp.task('pug', () => glue('pug'));
gulp.task('md', () => glue('md'));
gulp.task('ejs', () => glue('ejs'));
gulp.task('ts', () => {
let tsResult = tsProject.src()
.pipe(tsProject());
return tsResult.js.pipe(gulp.dest('lib'));
});
gulp.task('watch-ts', () => watch('ts'));
gulp.task('watch-pug', () => watch('pug'));
gulp.task('watch-ejs', () => watch('ejs'));
gulp.task('watch-md', () => watch('md'));
gulp.task('unit', ['build'], () => {
return gulp.src('test/unit/**/*.js', { read: false })
.pipe(mocha({ require: ['babel-register'] }));
});
gulp.task('it', ['build'], () => {
return gulp.src(['test/integration/init.js', 'test/integration/**/*-test.js'], { read: false })
.pipe(mocha({ bail: true, require: ['babel-register'] }))
.once('end', () => process.exit());
});
gulp.task('clean', (done) => {
fsExtra.remove('lib', done);
})
gulp.task('build', done => runSequence('clean', ['md', 'ejs', 'pug', 'ts'], done));
gulp.task('dev', ['build', 'watch-md', 'watch-ejs', 'watch-pug', 'watch-ts']);
gulp.task('test', ['unit']);