From 10b8ee4f54fdb077724381d32530c5c67c4b54be Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 6 Feb 2025 15:12:25 -0500 Subject: [PATCH] Fix bug when shell profile is not found (#1671) --- src/test/shell.test.ts | 5 +++++ src/utils/shell.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/shell.test.ts b/src/test/shell.test.ts index 51d0e85dc9..7e919f8a3b 100644 --- a/src/test/shell.test.ts +++ b/src/test/shell.test.ts @@ -78,6 +78,11 @@ describe("Shell Detection Tests", () => { expect(getShell()).to.equal("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") }) + it("handles undefined shell profile gracefully", () => { + mockVsCodeConfig("windows", "NonExistentProfile", {}) + expect(getShell()).to.equal("C:\\Windows\\System32\\cmd.exe") + }) + it("uses WSL bash when profile indicates WSL source", () => { mockVsCodeConfig("windows", "WSL", { WSL: { source: "WSL" }, diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 8871550a0e..2f7ffb3a88 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -105,7 +105,7 @@ function getWindowsShellFromVSCode(): string | null { } // If there's a specific path, return that immediately - if (profile.path) { + if (profile?.path) { return profile.path }