Skip to content

Commit 7d3c431

Browse files
committed
refactor: optimize file processing in generateDescriptions function using Promise.all
1 parent 619d3c2 commit 7d3c431

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/build/mdn-comments.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function generateDescriptions(): Promise<Record<string, string>> {
8989
try {
9090
const indexPaths = await walkDirectory(basePath);
9191

92-
for (const fileURL of indexPaths) {
92+
const promises = indexPaths.map(async (fileURL) => {
9393
try {
9494
const content = await fs.readFile(fileURL, "utf-8");
9595

@@ -110,7 +110,10 @@ export async function generateDescriptions(): Promise<Record<string, string>> {
110110
} catch (error) {
111111
console.warn(`Skipping ${fileURL.href}: ${error}`);
112112
}
113-
}
113+
});
114+
115+
// Wait for all file processing to finish
116+
await Promise.all(promises);
114117
} catch (error) {
115118
console.error("Error generating API descriptions:", error);
116119
}

0 commit comments

Comments
 (0)