From 882cbc96d431abd43314df0d064293d6b1cab1e0 Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Wed, 27 Aug 2025 20:53:00 -0700 Subject: [PATCH] fix: :bug: More windows specific fixes for powershell --- .../cli/src/tools/runTerminalCommand.test.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/cli/src/tools/runTerminalCommand.test.ts b/extensions/cli/src/tools/runTerminalCommand.test.ts index 6249f071c..dd85e472d 100644 --- a/extensions/cli/src/tools/runTerminalCommand.test.ts +++ b/extensions/cli/src/tools/runTerminalCommand.test.ts @@ -11,7 +11,7 @@ describe("runTerminalCommandTool", () => { let expectedOutput: string; if (isWindows) { - command = "echo hello world"; + command = 'Write-Output "hello world"'; expectedOutput = "hello world"; } else { command = 'echo "hello world"'; @@ -26,7 +26,7 @@ describe("runTerminalCommandTool", () => { let command: string; if (isWindows) { - command = "cd"; + command = "Get-Location | Select-Object -ExpandProperty Path"; } else { command = "pwd"; } @@ -34,10 +34,8 @@ describe("runTerminalCommandTool", () => { const result = await runTerminalCommandTool.run({ command }); if (isWindows) { - // Windows paths like C:\path\to\dir or with PowerShell output format - expect(result.trim()).toMatch( - /^([A-Za-z]:\\.*|Path\s+----\s+[A-Za-z]:\\.*)/m, - ); + // Windows paths like C:\path\to\dir + expect(result.trim()).toMatch(/^[A-Za-z]:\\.*/); } else { // Unix paths like /path/to/dir expect(result.trim()).toMatch(/^\/.*$/); @@ -48,7 +46,7 @@ describe("runTerminalCommandTool", () => { let command: string; if (isWindows) { - command = "dir /b"; + command = "Get-ChildItem | Select-Object -ExpandProperty Name"; } else { command = "ls"; } @@ -82,7 +80,7 @@ describe("runTerminalCommandTool", () => { if (isWindows) { it("should work with Windows commands", async () => { const result = await runTerminalCommandTool.run({ - command: "echo %OS%", + command: "Write-Output $env:OS", }); expect(result.trim()).toBe("Windows_NT"); });