Initialize productsPrice.json if it doesn't exist and update log message to Polish

This commit is contained in:
Norbert Maciaszek
2025-11-15 20:36:05 +01:00
parent 1559e4ccc9
commit a64edaf22f

View File

@@ -25,8 +25,11 @@ function sendMessage(message) {
}
async function compareAndSave(productsPrice) {
const productsPriceJson =
fs.readFileSync("productsPrice.json", "utf8") || "[]";
if (!fs.existsSync("productsPrice.json")) {
fs.writeFileSync("productsPrice.json", "[]");
}
const productsPriceJson = fs.readFileSync("productsPrice.json", "utf8");
const oldProductsPrice = JSON.parse(productsPriceJson);
const diffProducts = [];
@@ -139,7 +142,7 @@ async function init() {
await compareAndSave(productsPrice);
console.log("Done! Check productsPrice.json");
console.log("Sprawdzone! Aktualne ceny zapisane w productsPrice.json");
}
sendMessage("Zaczynam monitoring cen");