Skip to content

Commit

Permalink
feat(dependencies): show error if no package manager is installed
Browse files Browse the repository at this point in the history
Closes #45
  • Loading branch information
6km committed Jun 3, 2024
1 parent 997f096 commit 31934f2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/hooks/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ const registerInstallationHook = (
projectDependenciesHook.addHook(template, async ({ directoryPath }) => {
let installDeps = false

const installedPackageManagerNames = await Promise.all(
knownPackageManagerNames.map(checkPackageManagerInstalled),
).then((results) =>
knownPackageManagerNames.filter((_, index) => results[index]),
)

// show error message if no package manager is installed
if (!installedPackageManagerNames.length) {
console.log(
chalk.red('×'),
'No package manager found. Please install one any try again.',
)
return exit(1)
}

if (typeof installArg === 'boolean') {
installDeps = installArg
} else {
Expand All @@ -43,12 +58,6 @@ const registerInstallationHook = (

if (!installDeps) return

const installedPackageManagerNames = await Promise.all(
knownPackageManagerNames.map(checkPackageManagerInstalled),
).then((results) =>
knownPackageManagerNames.filter((_, index) => results[index]),
)

let packageManager

if (pmArg && installedPackageManagerNames.includes(pmArg)) {
Expand Down

0 comments on commit 31934f2

Please sign in to comment.