Skip to content

Commit ab23682

Browse files
committed
Add $BROWSER support for vscode remote development
1 parent b588c9c commit ab23682

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/portal/runtime/browser.cljc

+25-18
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,32 @@
8787
(filter some?))
8888
[(str "--app=" url)]))
8989

90+
(defn- get-browser []
91+
#?(:clj (System/getenv "BROWSER")
92+
:cljs (.-BROWSER js/process.env)
93+
:cljr (Environment/GetEnvironmentVariable "BROWSER")))
94+
9095
(defn- browse [url]
91-
#?(:clj
92-
(try (browse-url url)
93-
(catch Exception _e
94-
(println "Goto" url "to view portal ui.")))
95-
:cljs
96-
(case (.-platform js/process)
97-
("android" "linux") (shell/sh "xdg-open" url)
98-
"darwin" (shell/sh "open" url)
99-
"win32" (shell/sh "cmd" "/c" "start" url)
100-
(println "Goto" url "to view portal ui."))
101-
:cljr
102-
(condp identical? (.Platform Environment/OSVersion)
103-
PlatformID/Win32NT (shell/sh "cmd" "/c" "start" url)
104-
PlatformID/Win32Windows (shell/sh "cmd" "/c" "start" url)
105-
PlatformID/Unix (if (RuntimeInformation/IsOSPlatform OSPlatform/OSX)
106-
(shell/sh "open" url)
107-
(shell/sh "xdg-open" url))
108-
(println "Goto" url "to view portal ui."))))
96+
(or
97+
(some-> (get-browser) (shell/sh url))
98+
#?(:clj
99+
(try (browse-url url)
100+
(catch Exception _e
101+
(println "Goto" url "to view portal ui.")))
102+
:cljs
103+
(case (.-platform js/process)
104+
("android" "linux") (shell/sh "xdg-open" url)
105+
"darwin" (shell/sh "open" url)
106+
"win32" (shell/sh "cmd" "/c" "start" url)
107+
(println "Goto" url "to view portal ui."))
108+
:cljr
109+
(condp identical? (.Platform Environment/OSVersion)
110+
PlatformID/Win32NT (shell/sh "cmd" "/c" "start" url)
111+
PlatformID/Win32Windows (shell/sh "cmd" "/c" "start" url)
112+
PlatformID/Unix (if (RuntimeInformation/IsOSPlatform OSPlatform/OSX)
113+
(shell/sh "open" url)
114+
(shell/sh "xdg-open" url))
115+
(println "Goto" url "to view portal ui.")))))
109116

110117
#?(:clj (defn- random-uuid [] (java.util.UUID/randomUUID)))
111118

0 commit comments

Comments
 (0)