Skip to content

Commit 44b67b6

Browse files
committed
Now automatically creating output directories.
1 parent 640e6eb commit 44b67b6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function deinitTemplateRenderer(templateRenderer: ITemplateRenderer): Prom
2626
// Expand a template web page and capture it to an image file.
2727
//
2828
export async function captureImage(data: any, templatePath: string, outputPath: string): Promise<void> {
29+
await fs.ensureDir(path.dirname(outputPath));
2930
const autoAssignPortNo = 0; // Use port no 0, to automatically assign a port number.
3031
const templateRenderer = await initTemplateRenderer(data, templatePath, autoAssignPortNo);
3132
await templateRenderer.renderImage(outputPath);
@@ -36,6 +37,7 @@ export async function captureImage(data: any, templatePath: string, outputPath:
3637
// Expand a template web page and capture it to a PDF file.
3738
//
3839
export async function capturePDF(data: any, templatePath: string, outputPath: string): Promise<void> {
40+
await fs.ensureDir(path.dirname(outputPath));
3941
const autoAssignPortNo = 0; // Use port no 0, to automatically assign a port number.
4042
const templateRenderer = await initTemplateRenderer(data, templatePath, autoAssignPortNo);
4143
await templateRenderer.renderPDF(outputPath);

0 commit comments

Comments
 (0)