File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/integrations/terminal/__tests__/streamUtils Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,24 @@ export function createPowerShellStream(command: string): CommandStream {
1313
1414 try {
1515 // Execute the PowerShell command directly
16- // Wrap the command in double quotes to preserve it when passing to pwsh
17- const shellCommand = `pwsh -NoProfile -NonInteractive -Command "${ command . replace ( / " / g, '\\"' ) } "`
16+ // Use single quotes for the Command parameter to preserve PowerShell variables
17+ // Escape any single quotes in the command
18+ const escapedCommand = command . replace ( / ' / g, "'\\''" )
19+ const shellCommand = `pwsh -NoProfile -NonInteractive -Command '${ escapedCommand } '`
1820
1921 realOutput = execSync ( shellCommand , {
2022 encoding : "utf8" ,
2123 maxBuffer : 100 * 1024 * 1024 ,
22- stdio : [ "pipe" , "pipe" , "ignore " ] , // Redirect stderr to null
24+ stdio : [ "pipe" , "pipe" , "pipe " ] , // Capture stderr for debugging
2325 } )
2426 exitCode = 0 // Command succeeded
2527 } catch ( error : any ) {
2628 // Command failed - get output and exit code from error
2729 realOutput = error . stdout ?. toString ( ) || ""
30+ console . error ( `PowerShell command failed with status ${ error . status || "unknown" } :` , error . message )
31+ if ( error . stderr ) {
32+ console . error ( `stderr: ${ error . stderr . toString ( ) } ` )
33+ }
2834 exitCode = error . status || 1
2935 }
3036
You can’t perform that action at this time.
0 commit comments