File tree Expand file tree Collapse file tree
src/main/clojure/cljs/repl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 290290
291291(def lock (Object. ))
292292
293+ (defn- waiting-to-connect-message [url]
294+ (print-str " Waiting for browser to connect to" url " ..." ))
295+
296+ (defn- maybe-browse-url [base-url]
297+ (try
298+ (browse/browse-url (str base-url " ?rel=" (System/currentTimeMillis )))
299+ (catch Throwable t
300+ (if-some [error-message (not-empty (.getMessage t))]
301+ (println " Failed to launch a browser:\n " error-message " \n " )
302+ (println " Could not launch a browser.\n " ))
303+ (println " You can instead launch a non-browser REPL (Node or Nashorn).\n " )
304+ (println " You can disable automatic browser launch with this REPL option" )
305+ (println " :launch-browser false" )
306+ (println " and you can specify the listen IP address with this REPL option" )
307+ (println " :host \" 127.0.0.1\"\n " )
308+ (println (waiting-to-connect-message base-url)))))
309+
293310(defn setup [{:keys [working-dir launch-browser server-state] :as repl-env} {:keys [output-dir] :as opts}]
294311 (locking lock
295312 (when-not (:socket @server-state)
318335 (server/start repl-env)
319336 (let [base-url (str " http://" (:host repl-env) " :" (:port repl-env))]
320337 (if launch-browser
321- (browse/browse -url ( str base-url " ?rel= " ( System/currentTimeMillis )) )
322- (println " Waiting for browser to connect to " base-url " ... " ))))))
338+ (maybe- browse-url base-url)
339+ (println ( waiting-to- connect-message base-url) ))))))
323340 (swap! server-state update :listeners inc))
324341
325342(defrecord BrowserEnv []
You can’t perform that action at this time.
0 commit comments