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.FileSystemAllureWriter = void 0;
|
7 | const fs_1 = require("fs");
|
8 | const path_1 = require("path");
|
9 | const properties_1 = __importDefault(require("properties"));
|
10 | const writeJson = (path, data) => {
|
11 | (0, fs_1.writeFileSync)(path, JSON.stringify(data), { encoding: "utf-8" });
|
12 | };
|
13 | class FileSystemAllureWriter {
|
14 | constructor(config) {
|
15 | this.config = config;
|
16 | if (!(0, fs_1.existsSync)(this.config.resultsDir)) {
|
17 | (0, fs_1.mkdirSync)(this.config.resultsDir, {
|
18 | recursive: true,
|
19 | });
|
20 | }
|
21 | }
|
22 | writeAttachment(name, content, encoding = "utf-8") {
|
23 | const path = this.buildPath(name);
|
24 | (0, fs_1.writeFileSync)(path, content, { encoding });
|
25 | }
|
26 | writeAttachmentFromPath(from, distFileName) {
|
27 | const to = this.buildPath(distFileName);
|
28 | (0, fs_1.copyFileSync)(from, to);
|
29 | }
|
30 | writeEnvironmentInfo(info) {
|
31 | const text = properties_1.default.stringify(info, { unicode: true }).toString();
|
32 | const path = this.buildPath("environment.properties");
|
33 | (0, fs_1.writeFileSync)(path, text);
|
34 | }
|
35 | writeCategoriesDefinitions(categories) {
|
36 | const path = this.buildPath("categories.json");
|
37 | writeJson(path, categories);
|
38 | }
|
39 | writeGroup(result) {
|
40 | const path = this.buildPath(`${result.uuid}-container.json`);
|
41 | writeJson(path, result);
|
42 | }
|
43 | writeResult(result) {
|
44 | const path = this.buildPath(`${result.uuid}-result.json`);
|
45 | writeJson(path, result);
|
46 | }
|
47 | buildPath(name) {
|
48 | return (0, path_1.join)(this.config.resultsDir, name);
|
49 | }
|
50 | }
|
51 | exports.FileSystemAllureWriter = FileSystemAllureWriter;
|
52 |
|
\ | No newline at end of file |