From 8d90c0ec81dae1ab7d49106ac6e81a5b965fb78a Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Fri, 13 Oct 2023 01:18:32 +0530 Subject: [PATCH] chore: Use `Promise.all` in update script (#1926) --- update.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/update.ts b/update.ts index a611d335..d0ff4f2e 100644 --- a/update.ts +++ b/update.ts @@ -158,7 +158,7 @@ if (denoJson.compilerOptions?.jsx !== "react-jsx" && confirm(JSX_CODEMOD)) { join(resolvedDirectory, "**", "*.{js,jsx,ts,tsx}"), ); - for (const sf of sfs) { + await Promise.all(sfs.map((sf) => { for (const d of sf.getImportDeclarations()) { if (d.getModuleSpecifierValue() !== "preact") continue; for (const n of d.getNamedImports()) { @@ -179,8 +179,8 @@ if (denoJson.compilerOptions?.jsx !== "react-jsx" && confirm(JSX_CODEMOD)) { text = text.replaceAll("/** @jsxFrag Fragment */\n", ""); sf.replaceWithText(text); - await sf.save(); - } + return sf.save(); + })); } // Code mod for class={tw`border`} to class="border". @@ -226,7 +226,7 @@ await start(manifest, { plugins: [twindPlugin(twindConfig)] });\n`; join(resolvedDirectory, "**", "*.{js,jsx,ts,tsx}"), ); - for (const sf of sfs) { + await Promise.all(sfs.map((sf) => { const nodes = sf.forEachDescendantAsArray(); for (const n of nodes) { if (!n.wasForgotten() && Node.isJsxAttribute(n)) { @@ -271,8 +271,8 @@ await start(manifest, { plugins: [twindPlugin(twindConfig)] });\n`; } } - await sf.save(); - } + return sf.save(); + })); } // Add default _app.tsx if not present