@@ -59,7 +59,10 @@ func runWindowsExeInWSL(exePath string, args []string) ([]byte, error) {
5959
6060 cmd := exec .Command ("cmd.exe" , cmdArgs ... ) // #nosec G204
6161 output , err := cmd .CombinedOutput ()
62- return output , breverrors .WrapAndTrace (err )
62+ if err != nil {
63+ return nil , breverrors .WrapAndTrace (err )
64+ }
65+ return output , nil
6366}
6467
6568// This package should only be used as a holding pattern to be later moved into more specific packages
@@ -253,40 +256,27 @@ func runManyCursorCommand(cursorpaths []string, args []string) ([]byte, error) {
253256 return nil , breverrors .WrapAndTrace (errs .ErrorOrNil ())
254257}
255258
256- func runVsCodeCommand (vscodepath string , args []string ) ([]byte , error ) {
259+ // runEditorCommand runs an editor executable with the given args, handling WSL compatibility
260+ func runEditorCommand (path string , args []string ) ([]byte , error ) {
257261 // In WSL, Windows .exe files need to be run through cmd.exe
258- if isWSL () && (strings .HasSuffix (vscodepath , ".exe" ) || strings .HasPrefix (vscodepath , "/mnt/" )) {
259- res , err := runWindowsExeInWSL (vscodepath , args )
260- if err != nil {
261- return nil , breverrors .WrapAndTrace (err )
262- }
263- return res , nil
262+ if isWSL () && (strings .HasSuffix (path , ".exe" ) || strings .HasPrefix (path , "/mnt/" )) {
263+ return runWindowsExeInWSL (path , args )
264264 }
265265
266- cmd := exec .Command (vscodepath , args ... ) // #nosec G204
266+ cmd := exec .Command (path , args ... ) // #nosec G204
267267 res , err := cmd .CombinedOutput ()
268268 if err != nil {
269269 return nil , breverrors .WrapAndTrace (err )
270270 }
271271 return res , nil
272272}
273273
274- func runCursorCommand (cursorpath string , args []string ) ([]byte , error ) {
275- // In WSL, Windows .exe files need to be run through cmd.exe
276- if isWSL () && (strings .HasSuffix (cursorpath , ".exe" ) || strings .HasPrefix (cursorpath , "/mnt/" )) {
277- res , err := runWindowsExeInWSL (cursorpath , args )
278- if err != nil {
279- return nil , breverrors .WrapAndTrace (err )
280- }
281- return res , nil
282- }
274+ func runVsCodeCommand (vscodepath string , args []string ) ([]byte , error ) {
275+ return runEditorCommand (vscodepath , args )
276+ }
283277
284- cmd := exec .Command (cursorpath , args ... ) // #nosec G204
285- res , err := cmd .CombinedOutput ()
286- if err != nil {
287- return nil , breverrors .WrapAndTrace (err )
288- }
289- return res , nil
278+ func runCursorCommand (cursorpath string , args []string ) ([]byte , error ) {
279+ return runEditorCommand (cursorpath , args )
290280}
291281
292282func runManyWindsurfCommand (windsurfpaths []string , args []string ) ([]byte , error ) {
@@ -303,21 +293,7 @@ func runManyWindsurfCommand(windsurfpaths []string, args []string) ([]byte, erro
303293}
304294
305295func runWindsurfCommand (windsurfpath string , args []string ) ([]byte , error ) {
306- // In WSL, Windows .exe files need to be run through cmd.exe
307- if isWSL () && (strings .HasSuffix (windsurfpath , ".exe" ) || strings .HasPrefix (windsurfpath , "/mnt/" )) {
308- res , err := runWindowsExeInWSL (windsurfpath , args )
309- if err != nil {
310- return nil , breverrors .WrapAndTrace (err )
311- }
312- return res , nil
313- }
314-
315- cmd := exec .Command (windsurfpath , args ... ) // #nosec G204
316- res , err := cmd .CombinedOutput ()
317- if err != nil {
318- return nil , breverrors .WrapAndTrace (err )
319- }
320- return res , nil
296+ return runEditorCommand (windsurfpath , args )
321297}
322298
323299var commonVSCodePaths = []string {
0 commit comments