Skip to content

Commit

Permalink
astro/cli/install-package.ts: whichPm may return null if ran in an em…
Browse files Browse the repository at this point in the history
…pty directory (withastro#10782)
  • Loading branch information
nektro authored and PeterDraex committed Apr 23, 2024
1 parent a223b20 commit 1b79479
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/many-hairs-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Handles possible null value when calling `which-pm` during dynamic package installation
2 changes: 1 addition & 1 deletion packages/astro/src/cli/install-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function installPackage(
logger: Logger
): Promise<boolean> {
const cwd = options.cwd ?? process.cwd();
const packageManager = (await whichPm(cwd)).name ?? 'npm';
const packageManager = (await whichPm(cwd))?.name ?? 'npm';
const installCommand = getInstallCommand(packageNames, packageManager);

if (!installCommand) {
Expand Down

0 comments on commit 1b79479

Please sign in to comment.