From 109bf38a546c136e9b0b1028a2e17c8649aa6ca9 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 21 Feb 2024 22:46:44 -0600 Subject: [PATCH] refactor: Reduce `installPackage()` calls & switch back to silent --- src/index.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index c30404b..c264ad0 100755 --- a/src/index.js +++ b/src/index.js @@ -218,24 +218,20 @@ async function templateDir(from, to, useTS) { * @param {ConfigOptions} opts */ async function installDeps(to, packageManager, opts) { - await installPackage(['preact'], { packageManager, cwd: to }); + const dependencies = []; + const devDependencies = []; - if (opts.useTS) { - await installPackage(['typescript'], { packageManager, cwd: to, dev: true }); + const installOpts = { + packageManager, + cwd: to, + silent: true, } - if (opts.useRouter || opts.usePrerender) { - await installPackage(['preact-iso', 'preact-render-to-string'], { - packageManager, - cwd: to, - }); - } + if (opts.useTS) devDependencies.push('typescript'); + if (opts.useRouter) dependencies.push('preact-iso'); + if (opts.usePrerender) dependencies.push('preact-iso', 'preact-render-to-string') + if (opts.useESLint) devDependencies.push('eslint', 'eslint-config-preact'); - if (opts.useESLint) { - await installPackage(['eslint', 'eslint-config-preact'], { - packageManager, - cwd: to, - dev: true, - }); - } + await installPackage(dependencies, { ...installOpts }); + devDependencies.length && installPackage(devDependencies, { ...installOpts, dev: true}); }