1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.MessageAllureWriter = void 0;
|
7 | const fs_1 = require("fs");
|
8 | const properties_1 = __importDefault(require("properties"));
|
9 | const sendEvent = (event) => {
|
10 | var _a;
|
11 | (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, JSON.stringify(event));
|
12 | };
|
13 | const sendData = (path, type, data) => {
|
14 | sendEvent({ path, type, data: data.toString("base64") });
|
15 | };
|
16 | const writeJson = (path, type, data) => {
|
17 | sendData(path, type, Buffer.from(JSON.stringify(data)));
|
18 | };
|
19 | class MessageAllureWriter {
|
20 | writeAttachment(name, content, encoding = "utf-8") {
|
21 | sendData(name, "attachment", typeof content === "string" ? Buffer.from(content, encoding) : content);
|
22 | }
|
23 | writeAttachmentFromPath(from, distFileName) {
|
24 | sendData(distFileName, "attachment", (0, fs_1.readFileSync)(from));
|
25 | }
|
26 | writeEnvironmentInfo(info) {
|
27 | const text = properties_1.default.stringify(info, { unicode: true }).toString();
|
28 | sendData("environment.properties", "misc", Buffer.from(text));
|
29 | }
|
30 | writeCategoriesDefinitions(categories) {
|
31 | writeJson("categories.json", "misc", categories);
|
32 | }
|
33 | writeGroup(result) {
|
34 | writeJson(`${result.uuid}-container.json`, "container", result);
|
35 | }
|
36 | writeResult(result) {
|
37 | writeJson(`${result.uuid}-result.json`, "result", result);
|
38 | }
|
39 | }
|
40 | exports.MessageAllureWriter = MessageAllureWriter;
|
41 |
|
\ | No newline at end of file |