Parallelize reading files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
d36f62ea2b
commit
a624f664ef
1 changed files with 11 additions and 9 deletions
20
src/index.ts
20
src/index.ts
|
@ -129,15 +129,17 @@ interface Reports {
|
||||||
let reports: Reports = {};
|
let reports: Reports = {};
|
||||||
async function recurseDirectory(reports: Reports, path: string) {
|
async function recurseDirectory(reports: Reports, path: string) {
|
||||||
const dir = await readdir(path, { withFileTypes: true });
|
const dir = await readdir(path, { withFileTypes: true });
|
||||||
for (const file of dir) {
|
return await Promise.all(
|
||||||
const filePath = join(path, file.name);
|
dir.map(async (file) => {
|
||||||
if (file.isDirectory()) await recurseDirectory(reports, filePath);
|
const filePath = join(path, file.name);
|
||||||
else {
|
if (file.isDirectory()) await recurseDirectory(reports, filePath);
|
||||||
if (!file.name.endsWith(".html")) continue;
|
else {
|
||||||
const content = await readFile(filePath, "utf-8");
|
if (!file.name.endsWith(".html")) return;
|
||||||
reports[filePath] = await processFile(content);
|
const content = await readFile(filePath, "utf-8");
|
||||||
}
|
reports[filePath] = await processFile(content);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await recurseDirectory(reports, dirPath);
|
await recurseDirectory(reports, dirPath);
|
||||||
const totalThings = Object.values(reports)
|
const totalThings = Object.values(reports)
|
||||||
|
|
Loading…
Reference in a new issue