From fb759c693c4ed562046f8a670b75d5707eb96b61 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Thu, 29 Jun 2023 14:15:31 +0200 Subject: [PATCH] Fixed potential issue with log file being empty. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 93f5aca..34adcc2 100644 --- a/index.js +++ b/index.js @@ -244,7 +244,7 @@ async function runAll() { for (const vpn of vpns) { const currentDate = new Date(); const formattedDate = `${currentDate.getDate()}-${currentDate.getMonth() + 1}-${currentDate.getFullYear()}`; - const logEntries = JSON.parse(fs.readFileSync('batch_logs.json', 'utf8')); + const logEntries = JSON.parse(fs.readFileSync('batch_logs.json', 'utf8')) || []; const entry = logEntries.find(entries => entries.accountName === vpn); if (entry && entry.date === formattedDate) { logManager(`[${host}] ${vpn} already ran today!`, 'info');