File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package vscode
22
33import (
4+ "bytes"
45 "fmt"
56 "os"
67 "os/exec"
78 "path/filepath"
9+ "regexp"
810 "runtime"
11+ "strings"
912
1013 "github.com/recode-sh/cli/internal/system"
1114)
@@ -27,9 +30,29 @@ func (c CLI) Exec(arg ...string) (string, error) {
2730 return "" , err
2831 }
2932
30- cmdOutput , err := exec .Command (CLIPath , arg ... ). CombinedOutput ( )
33+ cmd := exec .Command (CLIPath , arg ... )
3134
32- return string (cmdOutput ), err
35+ var stdout bytes.Buffer
36+ var stderr bytes.Buffer
37+
38+ cmd .Stdout = & stdout
39+ cmd .Stderr = & stderr
40+
41+ err = cmd .Run ()
42+
43+ if err != nil {
44+ newLineRegExp := regexp .MustCompile (`\n+` )
45+
46+ return "" , fmt .Errorf (
47+ "Error while calling the Visual Studio Code CLI:\n \n %s\n \n %s" ,
48+ strings .TrimSpace (
49+ newLineRegExp .ReplaceAllLiteralString (stderr .String (), " " ),
50+ ),
51+ err .Error (),
52+ )
53+ }
54+
55+ return stdout .String (), nil
3356}
3457
3558func (c CLI ) LookupPath (operatingSystem string ) (string , error ) {
Original file line number Diff line number Diff line change @@ -8,5 +8,10 @@ func NewExtensions() Extensions {
88
99func (e Extensions ) Install (extensionName string ) (string , error ) {
1010 c := CLI {}
11- return c .Exec ("--install-extension" , extensionName , "--force" )
11+
12+ return c .Exec (
13+ "--install-extension" ,
14+ extensionName ,
15+ "--force" ,
16+ )
1217}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ func NewProcess() Process {
88
99func (p Process ) OpenOnRemote (hostKey , pathToOpen string ) (string , error ) {
1010 c := CLI {}
11+
1112 return c .Exec (
1213 "--new-window" ,
1314 "--skip-release-notes" ,
You can’t perform that action at this time.
0 commit comments