Skip to content

Commit

Permalink
Merge pull request #211 from giselles-ai/dont-download-font-every-time
Browse files Browse the repository at this point in the history
Stop unnecessary downloads during bun dev execution
  • Loading branch information
satococoa authored Dec 11, 2024
2 parents 32c70da + 9e74e22 commit e93f511
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions prepare-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ 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);
}
Expand Down

0 comments on commit e93f511

Please sign in to comment.