-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
61 lines (50 loc) · 1.46 KB
/
gulpfile.ts
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
// Lest you get too enamored with TypeScript, the Node build story is kind of
// still a piece of crap. Gulp seems to be the least-worst option at the moment
// but it still has way too much magical bullshit in it. Try using a function
// expression that isn't assigned to a module-scoped variable for example. You
// can't, so you can't define a higher-order function to create a pattern of
// tasks that you can then instantiate with different parameters. So basically
// a function is not a function due to quasi-syntactical bullshit.
import { dest, series, src } from "gulp";
import { pbjs, pbts } from "gulp-protobuf";
import { createProject } from "gulp-typescript";
//
// Defs
//
const project = createProject("tsconfig.json");
const protos = [
// Kizuna
"gk4_db_msg",
"pegasus",
// Maxiboost
"nue.protocol.exvs",
"nue.protocol.mms",
];
const protoFiles = protos.map(x => `protobuf/${x}.proto`);
const protojsFiles = protos.map(x => `generated/${x}.js`);
//
// Tasks
//
function generateJs() {
return src(protoFiles)
.pipe(
pbjs({
target: "static-module",
wrap: "commonjs",
})
)
.pipe(dest("generated"));
}
function generateTs() {
return src(protojsFiles)
.pipe(pbts({}))
.pipe(dest("generated"));
}
export function transpile() {
return project
.src()
.pipe(project())
.js.pipe(dest("bin"));
}
export const generate = series(generateJs, generateTs);
export default series(generate, transpile);