From c55ce7c2d3de2adf32fda15cf2e4d62c19e9d36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= <14854048+kripod@users.noreply.github.com> Date: Sat, 20 Apr 2024 10:25:31 +0200 Subject: [PATCH] fix (scraper): truncate files before writing to them --- src/content/quoteRecords/_scraper.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/quoteRecords/_scraper.ts b/src/content/quoteRecords/_scraper.ts index 80cd2cfc..edc3e21b 100644 --- a/src/content/quoteRecords/_scraper.ts +++ b/src/content/quoteRecords/_scraper.ts @@ -100,6 +100,7 @@ for (const [currency, rateByDate] of rateByDateByCurrency) { } quotes.sort(([aDate], [bDate]) => Date.parse(aDate) - Date.parse(bDate)); + await file.truncate(); await file.write( JSON.stringify(Object.fromEntries(quotes), null, 2) + "\n", 0,