Skip to content

Commit 05874c1

Browse files
committed
fix platform-unit-test error
1 parent 7b33bd5 commit 05874c1

File tree

1 file changed

+10
-2
lines changed
  • src/integrations/claude-code

1 file changed

+10
-2
lines changed

src/integrations/claude-code/run.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import * as vscode from "vscode"
22
import Anthropic from "@anthropic-ai/sdk"
33
import { execa } from "execa"
44

5-
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
5+
// Safely get the workspace folder, handling test environments
6+
const getCwd = () => {
7+
try {
8+
return vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
9+
} catch {
10+
// In test environments, vscode.workspace might not be available
11+
return undefined
12+
}
13+
}
614

715
export function runClaudeCode({
816
systemPrompt,
@@ -40,6 +48,6 @@ export function runClaudeCode({
4048
stdout: "pipe",
4149
stderr: "pipe",
4250
env: process.env,
43-
cwd,
51+
cwd: getCwd(),
4452
})
4553
}

0 commit comments

Comments
 (0)