-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
79 lines (72 loc) · 1.78 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
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const typedoc = require('gulp-typedoc');
const gulpClean = require('gulp-clean');
const terser = require('gulp-terser');
const eslint = require('gulp-eslint');
const pump = require('pump');
const ts = require('gulp-typescript');
const TO_CLEAN = ['dist', 'docs', '*.tgz'];
const SOURCE = 'src/**/*.ts';
const NAME = 'vk-chat-bot';
const DEST_FOLDER = 'dist';
const DOCS_FOLDER = './docs';
const TSCONFIG = 'tsconfig.json';
const ESLINTRC = '.eslintrc.json';
function clean(cb) {
pump(
[gulp.src(TO_CLEAN, { read: false, allowEmpty: true }), gulpClean()],
cb
);
}
function lint(cb) {
pump(
[
gulp.src(SOURCE),
eslint(ESLINTRC),
eslint.format(),
eslint.failAfterError(),
],
cb
);
}
function build(cb) {
const tsProject = ts.createProject(TSCONFIG);
let streams = pump([gulp.src(SOURCE), sourcemaps.init(), tsProject()]);
pump([streams.dts, gulp.dest(DEST_FOLDER)]);
pump(
[
streams.js,
terser(),
sourcemaps.write(),
gulp.dest(DEST_FOLDER),
],
cb
);
}
function docs(cb) {
pump(
[
gulp.src(SOURCE, { read: false }),
typedoc({
tsconfig: TSCONFIG,
out: DOCS_FOLDER,
name: NAME,
ignoreCompilerErrors: false,
listInvalidSymbolLinks: true,
logger: text => console.log(text),
}),
],
cb
);
}
exports.clean = clean;
exports.build = build;
exports.lint = lint;
exports.docs = docs;
exports.default = gulp.series(
exports.clean,
exports.build,
exports.lint,
exports.docs,
);