Skip to content

Commit

Permalink
feat(dependencies): hide install option if no package manager is inst…
Browse files Browse the repository at this point in the history
…alled. (#46)

* feat(dependencies): show error if no package manager is installed

Closes #45

* feat(dependencies): hide install option if no package manager detected

Closes #45

* fix if condition
  • Loading branch information
6km authored Jun 3, 2024
1 parent b83e6d9 commit 293536d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/hooks/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ 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]),
)

// hide install dependencies option if no package manager is installed
if (!installedPackageManagerNames.length) return

if (typeof installArg === 'boolean') {
installDeps = installArg
} else {
Expand All @@ -43,12 +52,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 293536d

Please sign in to comment.