From 6a81d1870ec7f589da793cc2c2e773da8c977071 Mon Sep 17 00:00:00 2001 From: Satoshi Ebisawa Date: Wed, 11 Dec 2024 15:52:37 +0900 Subject: [PATCH 1/2] Stop downloading everytime running bun dev --- prepare-font.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/prepare-font.js b/prepare-font.js index 5cea7f1e..9233b8c4 100644 --- a/prepare-font.js +++ b/prepare-font.js @@ -41,8 +41,13 @@ const downloadFile = async (url, destination) => { for (const file of filesToDownload) { try { - await downloadFile(file.url, file.destination); - console.log(`Downloaded: ${file.destination}`); + const fileExists = await fs.access(file.destination).then(() => true).catch(() => false); + if (!fileExists) { + await downloadFile(file.url, file.destination); + console.log(`Downloaded: ${file.destination}`); + } else { + console.log(`File already exists: ${file.destination}`); + } } catch (error) { console.error(`Error downloading ${file.url}:`, error); } From 9e74e22ee92553c695b0494c1320c15b76ff79bf Mon Sep 17 00:00:00 2001 From: Satoshi Ebisawa Date: Wed, 11 Dec 2024 16:54:27 +0900 Subject: [PATCH 2/2] bun check --- prepare-font.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prepare-font.js b/prepare-font.js index 9233b8c4..106e62a9 100644 --- a/prepare-font.js +++ b/prepare-font.js @@ -41,7 +41,10 @@ const downloadFile = async (url, destination) => { for (const file of filesToDownload) { try { - const fileExists = await fs.access(file.destination).then(() => true).catch(() => false); + const fileExists = await fs + .access(file.destination) + .then(() => true) + .catch(() => false); if (!fileExists) { await downloadFile(file.url, file.destination); console.log(`Downloaded: ${file.destination}`);