From acf0057863767ee30befba69ba53abd311d6ce17 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 26 Apr 2019 18:51:05 -0700 Subject: [PATCH] Add path to Chrome in Windows Subsystem for Linux --- main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c31b93d..d8bb605 100644 --- a/main.go +++ b/main.go @@ -225,6 +225,12 @@ chmod +x ` + codeServerPath func openBrowser(url string) { var openCmd *exec.Cmd + + const ( + macPath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" + wslPath = "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe" + ) + switch { case commandExists("google-chrome"): openCmd = exec.Command("google-chrome", chromeOptions(url)...) @@ -234,8 +240,10 @@ func openBrowser(url string) { openCmd = exec.Command("chromium", chromeOptions(url)...) case commandExists("chromium-browser"): openCmd = exec.Command("chromium-browser", chromeOptions(url)...) - case pathExists("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"): - openCmd = exec.Command("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", chromeOptions(url)...) + case pathExists(macPath): + openCmd = exec.Command(macPath, chromeOptions(url)...) + case pathExists(wslPath): + openCmd = exec.Command(wslPath, chromeOptions(url)...) default: err := browser.OpenURL(url) if err != nil {