Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit e56d351

Browse files
committed
Move browser opening into its own func
1 parent b20b1f9 commit e56d351

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,26 @@ chmod +x ~/bin/code-server
9090
break
9191
}
9292

93+
openBrowser(url)
94+
sshCmd.Wait()
95+
}
96+
97+
func openBrowser(url string) {
9398
var openCmd *exec.Cmd
9499
if commandExists("google-chrome") {
95100
openCmd = exec.Command("google-chrome", "--app="+url, "--disable-extensions", "--disable-plugins")
96101
} else if commandExists("firefox") {
97102
openCmd = exec.Command("firefox", "--url="+url, "-safe-mode")
103+
} else {
104+
flog.Info("unable to find a browser to open: sshcode only supports firefox and chrome")
105+
106+
return
98107
}
99108

100-
err = openCmd.Start()
109+
err := openCmd.Start()
101110
if err != nil {
102111
flog.Fatal("failed to open browser: %v", err)
103112
}
104-
sshCmd.Wait()
105113
}
106114

107115
// Checks if a command exists locally.

0 commit comments

Comments
 (0)