From aed9539ffd2de5fa5a868def55424d2529c723dd Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Sat, 3 Dec 2022 11:41:41 +0530 Subject: [PATCH 1/2] sanjaiyan: async func --- docgen/post-process.js | 16 +++++++--------- generate-esm-wrapper.js | 6 ++++-- generate-reports.js | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docgen/post-process.js b/docgen/post-process.js index 9c0a79bdcd..c73221712a 100644 --- a/docgen/post-process.js +++ b/docgen/post-process.js @@ -20,9 +20,11 @@ const path = require('path'); const readline = require('readline'); async function main() { - await applyExtras(); - await fixHomePage(); - await fixTitles(); + await Promise.all([ + applyExtras(), + fixHomePage(), + fixTitles(), + ]); } /** @@ -32,9 +34,7 @@ async function main() { */ async function applyExtras() { const extras = await getExtraFiles(); - for (const source of extras) { - await applyExtraContentFrom(source); - } + await Promise.all(extras.map((source) => applyExtraContentFrom(source))); } /** @@ -60,9 +60,7 @@ async function fixHomePage() { async function fixTitles() { const markdownDir = path.join(__dirname, 'markdown'); const files = await fs.readdir(markdownDir); - for (const file of files) { - await fixTitleOf(path.join(markdownDir, file)); - } + await Promise.all(files.map((file) => fixTitleOf(path.join(markdownDir, file)))); const tocFile = path.join(markdownDir, 'toc.yaml'); await fixTocTitles(tocFile); diff --git a/generate-esm-wrapper.js b/generate-esm-wrapper.js index 3d47c709d1..cba8527904 100644 --- a/generate-esm-wrapper.js +++ b/generate-esm-wrapper.js @@ -35,8 +35,10 @@ async function generateEsmWrapper(entryPoint, source) { const target = getTarget(entryPoint); const output = getEsmOutput(source, target); await fs.mkdir(path.dirname(target), { recursive: true }); - await fs.writeFile(target, output); - await fs.writeFile('./lib/esm/package.json', JSON.stringify({type: 'module'})); + await Promise.all([ + fs.writeFile(target, output), + fs.writeFile('./lib/esm/package.json', JSON.stringify({type: 'module'})) + ]); } function getTarget(entryPoint) { diff --git a/generate-reports.js b/generate-reports.js index 129c06e542..0f520c2210 100644 --- a/generate-reports.js +++ b/generate-reports.js @@ -35,10 +35,10 @@ const tempConfigFile = 'api-extractor.tmp'; async function generateReports() { const entryPoints = require('./entrypoints.json'); - for (const entryPoint in entryPoints) { + await Promise.all(entryPoints.map((entryPoint) => { const filePath = entryPoints[entryPoint].typings; - await generateReportForEntryPoint(entryPoint, filePath); - } + return generateReportForEntryPoint(entryPoint, filePath); + })); } async function generateReportForEntryPoint(entryPoint, filePath) { From 1d471aff22df1241461b8b918c82134440614df3 Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Wed, 27 Dec 2023 07:29:58 +0530 Subject: [PATCH 2/2] Update docgen/post-process.js Co-authored-by: Osman Jimenez --- docgen/post-process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docgen/post-process.js b/docgen/post-process.js index c73221712a..011735e11b 100644 --- a/docgen/post-process.js +++ b/docgen/post-process.js @@ -34,7 +34,7 @@ async function main() { */ async function applyExtras() { const extras = await getExtraFiles(); - await Promise.all(extras.map((source) => applyExtraContentFrom(source))); + await Promise.all(extras.map(applyExtraContentFrom)); } /**