Fix bug when shell profile is not found (#1671)

This commit is contained in:
Matt Rubens 2025-02-06 15:12:25 -05:00 committed by GitHub
parent 548338d39e
commit 10b8ee4f54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -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" },

View file

@ -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
}