From 3299879ad10d010fe3e8b29f12b830c2fa64f930 Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:00:56 -0700 Subject: [PATCH] Use fsp Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- lib/server/imageGenerator.js | 5 +++-- src/server/imageGenerator.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/server/imageGenerator.js b/lib/server/imageGenerator.js index 9b36841..fb874ff 100644 --- a/lib/server/imageGenerator.js +++ b/lib/server/imageGenerator.js @@ -29,8 +29,9 @@ class ImageGenerator { const absolutePath = path_1.default.join(this.outDir, imageName); const relativePath = path_1.default.join('/', this.args.dir, absolutePath.slice(this.outDir.length)); const svg = await this.satori(element, options); - const pngBuffer = new resvg_js_1.Resvg(svg).render().asPng(); - fs.writeFileSync(absolutePath, pngBuffer); + const resvg = new resvg_js_1.Resvg(svg); + const pngOutput = resvg.render(); + await fsp.writeFile(absolutePath, pngOutput.asPng()); const url = new URL(this.args.websiteUrl); url.pathname = relativePath; this.cache[hash] = { diff --git a/src/server/imageGenerator.ts b/src/server/imageGenerator.ts index 62d500e..8c48e1e 100644 --- a/src/server/imageGenerator.ts +++ b/src/server/imageGenerator.ts @@ -54,8 +54,9 @@ export class ImageGenerator { ) const svg = await this.satori(element, options) - const pngBuffer = new Resvg(svg).render().asPng(); - fs.writeFileSync(absolutePath, pngBuffer); + const resvg = new Resvg(svg); + const pngOutput = resvg.render(); + await fsp.writeFile(absolutePath, pngOutput.asPng()); const url = new URL(this.args.websiteUrl) url.pathname = relativePath