Fixed potential issue with log file being empty.

This commit is contained in:
2023-06-29 14:15:31 +02:00
parent 49086c0891
commit fb759c693c

View File

@@ -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');