-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (59 loc) · 1.73 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { series, parallel, src, dest } = require('gulp');
var gulp = require('gulp');
const gulp_prettier = require('gulp-prettier');
const ts = require('gulp-typescript');
const mocha = require('gulp-mocha');
const del = require('del');
const path = require('path');
exports.build = series(clean, pretty_check, parallel(build, copyconfigfiles));
exports.clean = clean;
exports.copyconfigfiles = copyconfigfiles;
exports.test = test;
exports.pretty = pretty;
exports.pretty_check = pretty_check;
exports.default = series(clean, pretty_check, parallel(build, copyconfigfiles));
const tsProject = ts.createProject('./tsconfig.json');
function build(cb) {
const merge = require('merge2');
var tsResult = tsProject.src().pipe(tsProject());
return merge([
tsResult.dts.pipe(dest('./definitions')),
tsResult.js.pipe(dest(tsProject.config.compilerOptions.outDir))
]);
}
function clean(cb) {
return del(['dist/**/*']);
}
function test(cb) {
return src('./dist/test/**/*.ts')
.pipe(tsProject())
.pipe(mocha({ require: ['ts-node/register'] }))
.on('end', function() {
cb();
});
}
function copyconfigfiles(cb) {
return src('./config/**/*.json').pipe(dest('./dist/config/'));
}
function pretty(cb) {
const merge = require('merge2');
return merge([tsProject.src(), src('./gulpfile.js')])
.pipe(
gulp_prettier({
config: './.prettierrc.js',
ignorePath: './prettierignore',
loglevel: 'debug'
})
)
.pipe(dest('.'));
}
function pretty_check(cb) {
const merge = require('merge2');
return merge([tsProject.src(), src('./gulpfile.js')]).pipe(
gulp_prettier.check({
config: './.prettierrc.js',
ignorePath: './prettierignore',
loglevel: 'debug'
})
);
}