From 7424fe19f822dc152315c1b1eb5f874512a88b55 Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Sat, 23 Mar 2024 02:45:27 +0530 Subject: [PATCH] =?UTF-8?q?perf:=20Supercharge=20Performance=20&=20Efficie?= =?UTF-8?q?ncy:=20Leveraging=20`Promise.all`=20for=20Resource-Friendly=20T?= =?UTF-8?q?asks=20=F0=9F=9A=A4=20(#838)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: Improve the performance by running it in concurrent * Update init.ts Small lint fix --------- Co-authored-by: Tony Coconate --- src/init.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/init.ts b/src/init.ts index 98e75f78..a0a2d945 100644 --- a/src/init.ts +++ b/src/init.ts @@ -322,18 +322,22 @@ export async function init(options: Options): Promise { generatedPackageJson = true; } - const addedDeps = await addDependencies(packageJson, options); - const addedScripts = await addScripts(packageJson, options); + const [addedDeps, addedScripts] = await Promise.all([ + addDependencies(packageJson, options), + addScripts(packageJson, options), + ]); if (generatedPackageJson || addedDeps || addedScripts) { await writePackageJson(packageJson, options); } else { options.logger.log('No edits needed in package.json.'); } - await generateTsConfig(options); - await generateESLintConfig(options); - await generateESLintIgnore(options); - await generatePrettierConfig(options); - await generateEditorConfig(options); + await Promise.all([ + generateTsConfig(options), + generateESLintConfig(options), + generateESLintIgnore(options), + generatePrettierConfig(options), + generateEditorConfig(options), + ]); await installDefaultTemplate(options); // Run `npm install` after initial setup so `npm run lint` works right away.