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) {
|
async function compareAndSave(productsPrice) {
|
||||||
const productsPriceJson =
|
if (!fs.existsSync("productsPrice.json")) {
|
||||||
fs.readFileSync("productsPrice.json", "utf8") || "[]";
|
fs.writeFileSync("productsPrice.json", "[]");
|
||||||
|
}
|
||||||
|
|
||||||
|
const productsPriceJson = fs.readFileSync("productsPrice.json", "utf8");
|
||||||
const oldProductsPrice = JSON.parse(productsPriceJson);
|
const oldProductsPrice = JSON.parse(productsPriceJson);
|
||||||
|
|
||||||
const diffProducts = [];
|
const diffProducts = [];
|
||||||
@@ -139,7 +142,7 @@ async function init() {
|
|||||||
|
|
||||||
await compareAndSave(productsPrice);
|
await compareAndSave(productsPrice);
|
||||||
|
|
||||||
console.log("Done! Check productsPrice.json");
|
console.log("Sprawdzone! Aktualne ceny zapisane w productsPrice.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage("Zaczynam monitoring cen");
|
sendMessage("Zaczynam monitoring cen");
|
||||||
|
|||||||
Reference in New Issue
Block a user