Add verify script

This commit is contained in:
Leandro Facchinetti 2020-03-23 12:48:21 -04:00
parent c5749d0b24
commit 5c3889b5b3
1 changed files with 21 additions and 0 deletions

21
src/verify.ts Normal file
View File

@ -0,0 +1,21 @@
import xml2js from "xml2js";
import fs from "fs";
(async () => {
for (const feed of fs
.readdirSync("static/feeds")
.filter(file => !file.startsWith("."))) {
try {
const xml = await new xml2js.Parser().parseStringPromise(
fs.readFileSync(`static/feeds/${feed}`, "utf8")
);
if (xml?.feed?.updated === undefined)
throw new Error("Cant find xml.feed.updated");
new xml2js.Builder().buildObject(xml);
console.log(`OK ${feed}`);
} catch (error) {
console.log(`ERROR ${feed}: ${error}`);
}
}
console.log("FINISHED");
})();