mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
astro/cli/install-package.ts: whichPm may return null if ran in an empty directory (#10782)
This commit is contained in:
parent
af1af9faee
commit
b0589d0553
2 changed files with 6 additions and 1 deletions
5
.changeset/many-hairs-jump.md
Normal file
5
.changeset/many-hairs-jump.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handles possible null value when calling `which-pm` during dynamic package installation
|
|
@ -101,7 +101,7 @@ async function installPackage(
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const cwd = options.cwd ?? process.cwd();
|
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);
|
const installCommand = getInstallCommand(packageNames, packageManager);
|
||||||
|
|
||||||
if (!installCommand) {
|
if (!installCommand) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue