Skip to content

Commit b0589d0

Browse files
authored
astro/cli/install-package.ts: whichPm may return null if ran in an empty directory (#10782)
1 parent af1af9f commit b0589d0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.changeset/many-hairs-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Handles possible null value when calling `which-pm` during dynamic package installation

packages/astro/src/cli/install-package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function installPackage(
101101
logger: Logger
102102
): Promise<boolean> {
103103
const cwd = options.cwd ?? process.cwd();
104-
const packageManager = (await whichPm(cwd)).name ?? 'npm';
104+
const packageManager = (await whichPm(cwd))?.name ?? 'npm';
105105
const installCommand = getInstallCommand(packageNames, packageManager);
106106

107107
if (!installCommand) {

0 commit comments

Comments
 (0)