-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (60 loc) · 1.78 KB
/
gulpfile.js
File metadata and controls
71 lines (60 loc) · 1.78 KB
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
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
ts = require('gulp-typescript'),
tsProject = ts.createProject('tsconfig.json'),
fsExtra = require('fs-extra'),
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}`, gulp.series(...tasks));
};
// individual tasks
function pug() { return glue('pug'); }
function md() { return glue('md'); }
function ejs() { return glue('ejs'); }
function tsCompile() {
let tsResult = tsProject.src().pipe(tsProject());
return tsResult.js.pipe(gulp.dest('lib'));
}
function clean(done) {
fsExtra.remove('lib', done);
}
function unit() {
return gulp
.src('test/unit/**/*.js', { read: false })
.pipe(mocha({ require: ['@babel/register'] }));
}
function it() {
return gulp
.src(['test/integration/init.js', 'test/integration/**/*-test.js'], { read: false })
.pipe(mocha({ bail: true, require: ['@babel/register'] }))
.once('end', () => process.exit());
}
// watch tasks
function watchTs() { return watch('ts'); }
function watchPug() { return watch('pug'); }
function watchEjs() { return watch('ejs'); }
function watchMd() { return watch('md'); }
// build pipeline
const build = gulp.series(
clean,
gulp.parallel(md, ejs, pug, tsCompile)
);
const dev = gulp.series(
build,
gulp.parallel(watchMd, watchEjs, watchPug, watchTs)
);
// task exports
exports.pug = pug;
exports.md = md;
exports.ejs = ejs;
exports.ts = tsCompile;
exports.clean = clean;
exports.unit = gulp.series(build, unit);
exports.it = gulp.series(build, it);
exports.build = build;
exports.dev = dev;
exports.test = exports.unit;