Initialize productsPrice.json if it doesn't exist and update log message to Polish
This commit is contained in:
9
index.js
9
index.js
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user