From 298a0362b2be17312c85d27059c42495fec1a85e Mon Sep 17 00:00:00 2001 From: NightScript <18664762+NightScript370@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:27:36 -0400 Subject: [PATCH] Make the dir through Bun.write, and await the ffmpeg requests --- bun.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bun.ts b/bun.ts index 70b236f..e547f08 100644 --- a/bun.ts +++ b/bun.ts @@ -73,14 +73,6 @@ for (const folder of await readdir("pages", { withFileTypes: true })) { })) }), accessURL); - const imagePath = `nitrofiles/pages/${rootPath}.gif` - if (await needsUpdate(imagePath, `pages/${dir}/${page}`)) { - await tab.screenshot({ path: tempFileNames.screenshot, clip: { x: 0, y: 0, width: 256, height: pageEval.height } }); - - $`ffmpeg -i ${tempFileNames.screenshot} -vf palettegen=max_colors=246 ${tempFileNames.palette} -y -loglevel error`; - $`ffmpeg -i ${tempFileNames.screenshot} -i ${tempFileNames.palette} -filter_complex paletteuse ${imagePath} -y -loglevel error`; - } - if (await needsUpdate(`nitrofiles/pages/${rootPath}.ini`, `pages/${dir}/${page}`)) { let iniContent = dedent(` [INFO] @@ -99,6 +91,14 @@ for (const folder of await readdir("pages", { withFileTypes: true })) { iniContent += iniLinks.join('\n\n') await Bun.write(`nitrofiles/pages/${rootPath}.ini`, iniContent.trim()); } + + const imagePath = `nitrofiles/pages/${rootPath}.gif` + if (await needsUpdate(imagePath, `pages/${dir}/${page}`)) { + await tab.screenshot({ path: tempFileNames.screenshot, clip: { x: 0, y: 0, width: 256, height: pageEval.height } }); + + await $`ffmpeg -i ${tempFileNames.screenshot} -vf palettegen=max_colors=246 ${tempFileNames.palette} -y -loglevel error`; + await $`ffmpeg -i ${tempFileNames.screenshot} -i ${tempFileNames.palette} -filter_complex paletteuse ${imagePath} -y -loglevel error`; + } } }