UNPKG

1.6 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.BepJsonWriter = exports.BepGenerator = void 0;
4/**
5 * @license
6 * Copyright Google Inc. All Rights Reserved.
7 *
8 * Use of this source code is governed by an MIT-style license that can be
9 * found in the LICENSE file at https://angular.io/license
10 */
11const fs = require("fs");
12class 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}
33exports.BepGenerator = BepGenerator;
34class 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}
55exports.BepJsonWriter = BepJsonWriter;