forked from olivierlsc/swagger-express-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·80 lines (74 loc) · 2.11 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
74
75
76
77
78
79
80
const gulp = require('gulp');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const clean = require('gulp-clean');
const tslint = require('gulp-tslint');
const path = {
src: 'src/**/*.ts',
dist: 'dist/swagger-express-ts',
module: 'node_modules/swagger-express-ts',
lib: {
src: 'lib/swagger-express-ts-lib/src/**/*.ts',
},
};
function cleanAll() {
return gulp
.src(['dist', path.module, '.nyc_output', 'coverage', '*.log*'], {
read: false,
allowEmpty: true,
})
.pipe(clean());
}
function buildLib() {
var tsProjectLib = ts.createProject('tsconfig.lib.json', {});
return gulp
.src([path.lib.src])
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(tsProjectLib())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.dist));
}
function buildModule() {
var tsProjectModule = ts.createProject('tsconfig.dev.lib.json', {});
return (
gulp
.src([path.lib.src])
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(tsProjectModule())
//.on ("error", function (err) {
// process.exit (1);
//})
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.module))
);
}
function copyFilesInDist() {
return gulp
.src([
'./README.md',
'./LICENSE',
'./CHANGELOG.md',
'./lib/swagger-express-ts-lib/package.json',
])
.pipe(gulp.dest(path.dist));
}
function tsLint() {
return gulp.src([path.src, path.lib.src]).pipe(
tslint({
formatter: 'verbose',
fix: true,
})
);
// .pipe(tslint.report())
// .pipe(
// tslintReporter({
// sort: true,
// filename: 'reports/checkstyle/results.xml',
// severity: 'error',
// })
// );
}
gulp.task('tslint', tsLint);
gulp.task('clean', cleanAll);
gulp.task('build:lib', gulp.series('clean', buildLib, copyFilesInDist));
gulp.task('build', gulp.series('clean', 'tslint', buildModule));