27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
|
|
const txt = fs.readFileSync('menu.txt', 'utf8');
|
|
const json = JSON.parse(fs.readFileSync('public/menu.json', 'utf8'));
|
|
|
|
const txtItemCount = (txt.match(/<div class="rmc-position"/g) || []).length;
|
|
const txtCategoryCount = (txt.match(/<div class="rm-category">/g) || []).length - 1; // -1 because the first split in the previous script had an empty category if there was a preceding tag? Actually, let's just count `class="restaurant-menu-category"`
|
|
|
|
const txtCatNameCount = (txt.match(/class="restaurant-menu-category">/g) || []).length;
|
|
|
|
|
|
let jsonItemCount = 0;
|
|
json.forEach(cat => {
|
|
jsonItemCount += cat.items.length;
|
|
});
|
|
|
|
console.log(`Menu.txt item count: ${txtItemCount}`);
|
|
console.log(`JSON item count: ${jsonItemCount}`);
|
|
console.log(`Menu.txt category count: ${txtCatNameCount}`);
|
|
console.log(`JSON category count: ${json.length}`);
|
|
|
|
if (txtItemCount === jsonItemCount && txtCatNameCount === json.length) {
|
|
console.log("MATCH: Wszystkie pozycje i kategorie zostały prawidłowo przeniesione.");
|
|
} else {
|
|
console.log("MISMATCH: Występują braki!");
|
|
}
|