Collect reports
This commit is contained in:
parent
1150850fed
commit
119969fcc1
1 changed files with 10 additions and 4 deletions
14
index.js
14
index.js
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue