Skip to content

Commit 08ce482

Browse files
authored
Merge pull request #782 from RooVetGit/safer_profile_path_check
Safer profile path check
2 parents 43f19d9 + d145039 commit 08ce482

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/heavy-feet-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Safer shell profile path check

src/utils/__tests__/shell.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ describe("Shell Detection Tests", () => {
9797
expect(getShell()).toBe("C:\\Windows\\System32\\cmd.exe")
9898
})
9999

100+
it("handles undefined profile gracefully", () => {
101+
// Mock a case where defaultProfileName exists but the profile doesn't
102+
mockVsCodeConfig("windows", "NonexistentProfile", {})
103+
expect(getShell()).toBe("C:\\Windows\\System32\\cmd.exe")
104+
})
105+
100106
it("respects userInfo() if no VS Code config is available", () => {
101107
vscode.workspace.getConfiguration = () => ({ get: () => undefined }) as any
102108
;(userInfo as any) = () => ({ shell: "C:\\Custom\\PowerShell.exe" })

src/utils/shell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function getWindowsShellFromVSCode(): string | null {
105105
}
106106

107107
// If there's a specific path, return that immediately
108-
if (profile.path) {
108+
if (profile?.path) {
109109
return profile.path
110110
}
111111

0 commit comments

Comments
 (0)