Collect reports

This commit is contained in:
Cat /dev/Nulo 2022-11-25 19:07:13 -03:00
parent 1150850fed
commit 119969fcc1

View file

@ -85,18 +85,24 @@ function processFile(content) {
});
}
async function recurseDirectory(path) {
let reports = [];
async function recurseDirectory(reports, path) {
const dir = await readdir(path, { withFileTypes: true });
for (const file of dir) {
const filePath = join(path, file.name);
if (file.isDirectory()) recurseDirectory(filePath);
if (file.isDirectory()) await recurseDirectory(reports, filePath);
else {
if (!file.name.endsWith(".html")) continue;
const content = await readFile(filePath, "utf-8");
console.time(filePath);
await processFile(content);
reports.push(await processFile(content));
console.timeEnd(filePath);
}
}
}
await recurseDirectory(dirPath);
await recurseDirectory(reports, dirPath);
const totalWarnings = reports.map((r) => r.warnings).flat();
console.log(
`Finished with ${reports.length} files read, ${totalWarnings.length} warnings`,
totalWarnings
);