Skip to content

Commit

Permalink
refactor: Reduce installPackage() calls & switch back to silent (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Feb 22, 2024
1 parent ac22d50 commit 4f277b8
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}

0 comments on commit 4f277b8

Please sign in to comment.