0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

astro/cli/install-package.ts: whichPm may return null if ran in an empty directory (#10782)

This commit is contained in:
Meghan Denny 2024-04-15 02:12:07 -07:00 committed by GitHub
parent af1af9faee
commit b0589d0553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Handles possible null value when calling `which-pm` during dynamic package installation

View file

@ -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) {