1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.BepJsonWriter = exports.BepGenerator = void 0;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const fs = require("fs");
|
12 | class BepGenerator {
|
13 | constructor() { }
|
14 | static createBuildStarted(command, time) {
|
15 | return {
|
16 | id: { started: {} },
|
17 | started: {
|
18 | command,
|
19 | start_time_millis: time == undefined ? Date.now() : time,
|
20 | },
|
21 | };
|
22 | }
|
23 | static createBuildFinished(code, time) {
|
24 | return {
|
25 | id: { finished: {} },
|
26 | finished: {
|
27 | finish_time_millis: time == undefined ? Date.now() : time,
|
28 | exit_code: { code },
|
29 | },
|
30 | };
|
31 | }
|
32 | }
|
33 | exports.BepGenerator = BepGenerator;
|
34 | class BepJsonWriter {
|
35 | constructor(filename) {
|
36 | this.filename = filename;
|
37 | this.stream = fs.createWriteStream(this.filename);
|
38 | }
|
39 | close() {
|
40 | this.stream.close();
|
41 | }
|
42 | writeEvent(event) {
|
43 | const raw = JSON.stringify(event);
|
44 | this.stream.write(raw + '\n');
|
45 | }
|
46 | writeBuildStarted(command, time) {
|
47 | const event = BepGenerator.createBuildStarted(command, time);
|
48 | this.writeEvent(event);
|
49 | }
|
50 | writeBuildFinished(code, time) {
|
51 | const event = BepGenerator.createBuildFinished(code, time);
|
52 | this.writeEvent(event);
|
53 | }
|
54 | }
|
55 | exports.BepJsonWriter = BepJsonWriter;
|