chromiumly 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -40
- package/dist/chromium/converters/converter.d.ts +13 -0
- package/dist/chromium/converters/converter.js +10 -0
- package/dist/chromium/converters/converter.js.map +1 -1
- package/dist/chromium/converters/html.converter.d.ts +32 -6
- package/dist/chromium/converters/html.converter.js +30 -9
- package/dist/chromium/converters/html.converter.js.map +1 -1
- package/dist/chromium/converters/markdown.converter.d.ts +34 -7
- package/dist/chromium/converters/markdown.converter.js +32 -16
- package/dist/chromium/converters/markdown.converter.js.map +1 -1
- package/dist/chromium/converters/url.converter.d.ts +31 -5
- package/dist/chromium/converters/url.converter.js +29 -1
- package/dist/chromium/converters/url.converter.js.map +1 -1
- package/dist/chromium/index.js.map +1 -1
- package/dist/chromium/interfaces/converter.types.d.ts +3 -6
- package/dist/chromium/utils/converter.utils.d.ts +27 -1
- package/dist/chromium/utils/converter.utils.js +48 -21
- package/dist/chromium/utils/converter.utils.js.map +1 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/gotenberg.utils.d.ts +18 -0
- package/dist/common/gotenberg.utils.js +18 -0
- package/dist/common/gotenberg.utils.js.map +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/types.d.ts +3 -0
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -0
- package/dist/gotenberg.d.ts +8 -0
- package/dist/gotenberg.js +8 -0
- package/dist/gotenberg.js.map +1 -1
- package/dist/libre-office/index.js.map +1 -1
- package/dist/libre-office/utils/constants.js +76 -76
- package/dist/libre-office/utils/constants.js.map +1 -1
- package/dist/libre-office/utils/libre-office.utils.d.ts +19 -4
- package/dist/libre-office/utils/libre-office.utils.js +39 -7
- package/dist/libre-office/utils/libre-office.utils.js.map +1 -1
- package/dist/main.config.d.ts +43 -0
- package/dist/main.config.js +43 -0
- package/dist/main.config.js.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/pdf-engines/index.js.map +1 -1
- package/dist/pdf-engines/pdf.engine.d.ts +31 -5
- package/dist/pdf-engines/pdf.engine.js +31 -3
- package/dist/pdf-engines/pdf.engine.js.map +1 -1
- package/dist/pdf-engines/utils/engine.utils.d.ts +12 -3
- package/dist/pdf-engines/utils/engine.utils.js +27 -8
- package/dist/pdf-engines/utils/engine.utils.js.map +1 -1
- package/package.json +8 -7
- package/src/chromium/converters/converter.ts +18 -5
- package/src/chromium/converters/html.converter.ts +82 -61
- package/src/chromium/converters/markdown.converter.ts +86 -69
- package/src/chromium/converters/tests/html.converter.test.ts +119 -135
- package/src/chromium/converters/tests/markdown.converter.test.ts +131 -150
- package/src/chromium/converters/tests/url.converter.test.ts +114 -123
- package/src/chromium/converters/url.converter.ts +84 -60
- package/src/chromium/index.ts +3 -3
- package/src/chromium/interfaces/converter.types.ts +27 -27
- package/src/chromium/utils/converter.utils.ts +165 -139
- package/src/chromium/utils/tests/converter.utils.test.ts +312 -311
- package/src/common/constants.ts +3 -3
- package/src/common/gotenberg.utils.ts +36 -17
- package/src/common/index.ts +3 -2
- package/src/common/tests/gotenberg.utils.test.ts +54 -54
- package/src/common/types.ts +3 -0
- package/src/gotenberg.ts +13 -4
- package/src/libre-office/index.ts +2 -2
- package/src/libre-office/interfaces/libre-office.types.ts +2 -2
- package/src/libre-office/utils/constants.ts +76 -76
- package/src/libre-office/utils/libre-office.utils.ts +72 -37
- package/src/libre-office/utils/tests/libre-office.utils.test.ts +100 -68
- package/src/main.config.ts +68 -22
- package/src/main.ts +3 -3
- package/src/pdf-engines/index.ts +1 -1
- package/src/pdf-engines/pdf.engine.ts +77 -49
- package/src/pdf-engines/tests/pdf.engine.test.ts +94 -94
- package/src/pdf-engines/utils/engine.utils.ts +30 -12
- package/src/pdf-engines/utils/tests/engine.utils.test.ts +60 -48
|
@@ -1,86 +1,118 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {promises, createReadStream} from "fs";
|
|
3
|
+
import {LibreOfficeUtils} from "../libre-office.utils";
|
|
4
4
|
|
|
5
5
|
import FormData from "form-data";
|
|
6
|
+
import FileType from "file-type";
|
|
6
7
|
|
|
7
8
|
describe("LibreOfficeUtils", () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const mockPromisesAccess = jest.spyOn(promises, "access");
|
|
10
|
+
const mockFormDataAppend = jest.spyOn(FormData.prototype, "append");
|
|
11
|
+
const mockFromBuffer = jest.spyOn(FileType, "fromBuffer");
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
(createReadStream as jest.Mock) = jest
|
|
14
|
-
.fn()
|
|
15
|
-
.mockImplementation((file) => file);
|
|
16
|
-
});
|
|
13
|
+
const data = new FormData();
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
describe("injectFiles", () => {
|
|
23
|
-
describe("when files exist", () => {
|
|
24
|
-
it("should append each file to data", async () => {
|
|
25
|
-
mockPromisesAccess.mockResolvedValue();
|
|
26
|
-
await LibreOfficeUtils.injectFiles(
|
|
27
|
-
["path/to/file.docx", "path/to/file.bib"],
|
|
28
|
-
data
|
|
29
|
-
);
|
|
30
|
-
expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
|
|
31
|
-
});
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
(createReadStream as jest.Mock) = jest
|
|
17
|
+
.fn()
|
|
18
|
+
.mockImplementation((file) => file);
|
|
32
19
|
});
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mockPromisesAccess.mockResolvedValue();
|
|
37
|
-
await expect(() =>
|
|
38
|
-
LibreOfficeUtils.injectFiles(
|
|
39
|
-
["path/to/file.rar", "path/to/file.pdf"],
|
|
40
|
-
data
|
|
41
|
-
)
|
|
42
|
-
).rejects.toThrow(".rar is not supported");
|
|
43
|
-
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
jest.resetAllMocks();
|
|
44
23
|
});
|
|
45
24
|
|
|
46
|
-
describe("
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
25
|
+
describe("addFiles", () => {
|
|
26
|
+
describe("when files exist", () => {
|
|
27
|
+
describe("when files parameter contains paths", () => {
|
|
28
|
+
it("should append each file to data", async () => {
|
|
29
|
+
mockPromisesAccess.mockResolvedValue();
|
|
30
|
+
await LibreOfficeUtils.addFiles(
|
|
31
|
+
["path/to/file.docx", "path/to/file.bib"],
|
|
32
|
+
data
|
|
33
|
+
);
|
|
34
|
+
expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
describe("when files parameter contains a buffer", () => {
|
|
38
|
+
it("should append each file to data", async () => {
|
|
39
|
+
mockPromisesAccess.mockResolvedValueOnce();
|
|
40
|
+
mockFromBuffer.mockResolvedValueOnce({
|
|
41
|
+
ext: "docx",
|
|
42
|
+
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
43
|
+
})
|
|
44
|
+
await LibreOfficeUtils.addFiles(
|
|
45
|
+
[Buffer.from("data"), "path/to/file.bib"],
|
|
46
|
+
data
|
|
47
|
+
);
|
|
48
|
+
expect(mockFormDataAppend).toHaveBeenCalledTimes(2);
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("when one of the files has undetermined format", () => {
|
|
54
|
+
it("should throw an error", async () => {
|
|
55
|
+
mockPromisesAccess.mockResolvedValueOnce();
|
|
56
|
+
mockFromBuffer.mockResolvedValueOnce(undefined
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
await expect(LibreOfficeUtils.addFiles(
|
|
60
|
+
[Buffer.from("data"), "path/to/file.bib"],
|
|
61
|
+
data
|
|
62
|
+
)).rejects.toThrow("File type could not be determined");
|
|
63
|
+
});
|
|
64
|
+
})
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
describe("when one of the files has unsupported format", () => {
|
|
67
|
+
it("should throw an error", async () => {
|
|
68
|
+
mockPromisesAccess.mockResolvedValueOnce();
|
|
69
|
+
await expect(() =>
|
|
70
|
+
LibreOfficeUtils.addFiles(
|
|
71
|
+
["path/to/file.rar", "path/to/file.pdf"],
|
|
72
|
+
data
|
|
73
|
+
)
|
|
74
|
+
).rejects.toThrow("rar is not supported");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("when one of the files does not exist", () => {
|
|
79
|
+
it("should throw an error", async () => {
|
|
80
|
+
const errorMessage =
|
|
81
|
+
"ENOENT: no such file or directory, access 'path/to/index.html'";
|
|
82
|
+
mockPromisesAccess.mockRejectedValueOnce(new Error(errorMessage));
|
|
83
|
+
await expect(() =>
|
|
84
|
+
LibreOfficeUtils.addFiles(
|
|
85
|
+
["path/to/file.pdf", "path/to/another-file.pdf"],
|
|
86
|
+
data
|
|
87
|
+
)
|
|
88
|
+
).rejects.toThrow(errorMessage);
|
|
89
|
+
});
|
|
70
90
|
});
|
|
71
|
-
});
|
|
72
91
|
});
|
|
73
92
|
|
|
74
|
-
describe("
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
describe("addPageProperties", () => {
|
|
94
|
+
describe("Page landscape", () => {
|
|
95
|
+
describe("when landscape parameter is set", () => {
|
|
96
|
+
it("should append landscape to data", () => {
|
|
97
|
+
LibreOfficeUtils.addPageProperties(data, {
|
|
98
|
+
landscape: true,
|
|
99
|
+
});
|
|
100
|
+
expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
|
|
101
|
+
expect(data.append).toHaveBeenCalledWith("landscape", "true");
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("Page ranges", () => {
|
|
107
|
+
describe("when nativePageRanges is valid", () => {
|
|
108
|
+
it("should append nativePageRanges to data", () => {
|
|
109
|
+
LibreOfficeUtils.addPageProperties(data, {
|
|
110
|
+
nativePageRanges: {from: 1, to: 6},
|
|
111
|
+
});
|
|
112
|
+
expect(mockFormDataAppend).toHaveBeenCalledTimes(1);
|
|
113
|
+
expect(data.append).toHaveBeenCalledWith("nativePageRanges", "1-6");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
82
116
|
});
|
|
83
|
-
});
|
|
84
117
|
});
|
|
85
|
-
});
|
|
86
118
|
});
|
package/src/main.config.ts
CHANGED
|
@@ -1,36 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Gotenberg} from "./gotenberg";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Enum representing the available Chromium routes for conversion.
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
3
7
|
export enum ChromiumRoute {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
URL = "url",
|
|
9
|
+
HTML = "html",
|
|
10
|
+
MARKDOWN = "markdown",
|
|
7
11
|
}
|
|
8
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Enum representing the available routes for the PDF engine.
|
|
15
|
+
* @enum {string}
|
|
16
|
+
*/
|
|
9
17
|
enum PdfEngineRoute {
|
|
10
|
-
|
|
18
|
+
MERGE = "merge",
|
|
11
19
|
}
|
|
12
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Enum representing the available routes for LibreOffice.
|
|
23
|
+
* @enum {string}
|
|
24
|
+
*/
|
|
13
25
|
enum LibreOfficeRoute {
|
|
14
|
-
|
|
26
|
+
CONVERT = "convert",
|
|
15
27
|
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Class providing constants and routes for interacting with the Gotenberg service and related engines.
|
|
31
|
+
*/
|
|
16
32
|
export class Chromiumly {
|
|
17
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The Gotenberg service endpoint.
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
public static readonly GOTENBERG_ENDPOINT = Gotenberg.endpoint;
|
|
18
38
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The path for Chromium-related conversions.
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
public static readonly CHROMIUM_PATH = "forms/chromium/convert";
|
|
22
44
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The path for PDF engine-related operations.
|
|
47
|
+
* @type {string}
|
|
48
|
+
*/
|
|
49
|
+
public static readonly PDF_ENGINES_PATH = "forms/pdfengines";
|
|
28
50
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The path for LibreOffice-related conversions.
|
|
53
|
+
* @type {string}
|
|
54
|
+
*/
|
|
55
|
+
public static readonly LIBRE_OFFICE_PATH = "forms/libreoffice";
|
|
32
56
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Routes for Chromium conversions.
|
|
59
|
+
* @type {Object}
|
|
60
|
+
*/
|
|
61
|
+
public static readonly CHROMIUM_ROUTES = {
|
|
62
|
+
url: ChromiumRoute.URL,
|
|
63
|
+
html: ChromiumRoute.HTML,
|
|
64
|
+
markdown: ChromiumRoute.MARKDOWN,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Routes for PDF engine operations.
|
|
69
|
+
* @type {Object}
|
|
70
|
+
*/
|
|
71
|
+
public static readonly PDF_ENGINE_ROUTES = {
|
|
72
|
+
merge: PdfEngineRoute.MERGE,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Routes for LibreOffice conversions.
|
|
77
|
+
* @type {Object}
|
|
78
|
+
*/
|
|
79
|
+
public static readonly LIBRE_OFFICE_ROUTES = {
|
|
80
|
+
convert: LibreOfficeRoute.CONVERT,
|
|
81
|
+
};
|
|
82
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export {PdfFormat} from "./common/constants";
|
|
2
|
+
export {HtmlConverter, MarkdownConverter, UrlConverter} from "./chromium";
|
|
3
|
+
export {PDFEngine} from "./pdf-engines";
|
package/src/pdf-engines/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {PDFEngine} from "./pdf.engine";
|
|
@@ -1,65 +1,93 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {promises} from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
import FormData from "form-data";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import {Chromiumly} from "../main.config";
|
|
7
|
+
import {GotenbergUtils, PathLikeOrReadStream, PdfFormat} from "../common";
|
|
8
|
+
import {LibreOfficeUtils, PageProperties} from "../libre-office";
|
|
9
|
+
import {PDFEngineUtils} from "./utils/engine.utils";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Class representing a PDF engine for various operations such as merging and conversion.
|
|
13
|
+
*/
|
|
11
14
|
export class PDFEngine {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Merges multiple PDF files into a single PDF document.
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} options - Options for the merge operation.
|
|
19
|
+
* @param {PathLikeOrReadStream[]} options.files - An array of PathLikes or ReadStreams to the PDF files to be merged.
|
|
20
|
+
* @returns {Promise<Buffer>} A Promise resolving to the merged PDF content as a Buffer.
|
|
21
|
+
*/
|
|
22
|
+
public static async merge({files}: { files: PathLikeOrReadStream[] }): Promise<Buffer> {
|
|
23
|
+
const data = new FormData();
|
|
24
|
+
await PDFEngineUtils.addFiles(files, data);
|
|
25
|
+
const endpoint = `${Chromiumly.GOTENBERG_ENDPOINT}/${Chromiumly.PDF_ENGINES_PATH}/${Chromiumly.PDF_ENGINE_ROUTES.merge}`;
|
|
26
|
+
return GotenbergUtils.fetch(endpoint, data);
|
|
27
|
+
}
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Converts various document formats to PDF.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} options - Options for the conversion operation.
|
|
33
|
+
* @param {PathLikeOrReadStream[]} options.files - An array of PathLikes or ReadStreams to the files to be converted to PDF.
|
|
34
|
+
* @param {PageProperties} [options.properties] - Page properties for the conversion.
|
|
35
|
+
* @param {PdfFormat} [options.pdfFormat] - PDF format options.
|
|
36
|
+
* @param {boolean} [options.pdfUA] - Indicates whether to generate PDF/UA compliant output.
|
|
37
|
+
* @param {boolean} [options.merge] - Indicates whether to merge the resulting PDFs.
|
|
38
|
+
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a Buffer.
|
|
39
|
+
*/
|
|
40
|
+
public static async convert({
|
|
41
|
+
files,
|
|
42
|
+
properties,
|
|
43
|
+
pdfFormat,
|
|
44
|
+
pdfUA,
|
|
45
|
+
merge,
|
|
46
|
+
}: {
|
|
47
|
+
files: PathLikeOrReadStream[];
|
|
48
|
+
properties?: PageProperties;
|
|
49
|
+
pdfFormat?: PdfFormat;
|
|
50
|
+
pdfUA?: boolean;
|
|
51
|
+
merge?: boolean;
|
|
52
|
+
}): Promise<Buffer> {
|
|
53
|
+
const data = new FormData();
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
if (pdfFormat) {
|
|
56
|
+
data.append("pdfa", pdfFormat);
|
|
57
|
+
}
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
if (pdfUA) {
|
|
60
|
+
data.append("pdfUA", String(pdfUA));
|
|
61
|
+
}
|
|
41
62
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
if (merge) {
|
|
64
|
+
data.append("merge", String(merge));
|
|
65
|
+
}
|
|
45
66
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
if (properties) {
|
|
68
|
+
LibreOfficeUtils.addPageProperties(data, properties);
|
|
69
|
+
}
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
await LibreOfficeUtils.addFiles(files, data);
|
|
51
72
|
|
|
52
|
-
|
|
73
|
+
const endpoint = `${Chromiumly.GOTENBERG_ENDPOINT}/${Chromiumly.LIBRE_OFFICE_PATH}/${Chromiumly.LIBRE_OFFICE_ROUTES.convert}`;
|
|
53
74
|
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
return GotenbergUtils.fetch(endpoint, data);
|
|
76
|
+
}
|
|
56
77
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Generates a PDF file from a buffer and saves it to the "__generated__" directory.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} filename - The filename for the generated PDF.
|
|
82
|
+
* @param {Buffer} buffer - The PDF content as a Buffer.
|
|
83
|
+
* @returns {Promise<void>} A Promise that resolves once the file is generated and saved.
|
|
84
|
+
*/
|
|
85
|
+
public static async generate(
|
|
86
|
+
filename: string,
|
|
87
|
+
buffer: Buffer
|
|
88
|
+
): Promise<void> {
|
|
89
|
+
const __generated__ = path.resolve(process.cwd(), "__generated__");
|
|
90
|
+
await promises.mkdir(path.resolve(__generated__), {recursive: true});
|
|
91
|
+
await promises.writeFile(path.resolve(__generated__, filename), buffer);
|
|
92
|
+
}
|
|
65
93
|
}
|