From e121c5a132839b22e72b39ba46221b911999f0fc Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 12 Apr 2024 20:48:35 -0700 Subject: [PATCH 1/2] astro/cli/install-package.ts: whichPm may return null if ran in an empty directory --- packages/astro/src/cli/install-package.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/cli/install-package.ts b/packages/astro/src/cli/install-package.ts index 02e856846484..7c8601e48a8c 100644 --- a/packages/astro/src/cli/install-package.ts +++ b/packages/astro/src/cli/install-package.ts @@ -101,7 +101,7 @@ async function installPackage( logger: Logger ): Promise { 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) { From f89d5fdda669168753ace939a396a5e14be43bad Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 15 Apr 2024 17:10:34 +0800 Subject: [PATCH 2/2] Create many-hairs-jump.md --- .changeset/many-hairs-jump.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/many-hairs-jump.md diff --git a/.changeset/many-hairs-jump.md b/.changeset/many-hairs-jump.md new file mode 100644 index 000000000000..2e855708fb89 --- /dev/null +++ b/.changeset/many-hairs-jump.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Handles possible null value when calling `which-pm` during dynamic package installation