Skip to content

Commit eaf67ed

Browse files
authored
put the browser REPL new window behavior behind a flag, default to false (#284)
1 parent 1a3d19e commit eaf67ed

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/main/clojure/cljs/repl/browser.clj

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,27 @@
349349
(defn- waiting-to-connect-message [url]
350350
(print-str "Waiting for browser to connect to" url "..."))
351351

352-
(defn- maybe-browse-url [base-url]
353-
(try
354-
(browse/browse-url (str base-url "?rel=" (System/currentTimeMillis)))
355-
(catch Throwable t
356-
(if-some [error-message (not-empty (.getMessage t))]
357-
(println "Failed to launch a browser:\n" error-message "\n")
358-
(println "Could not launch a browser.\n"))
359-
(println "You can instead launch a non-browser REPL (Node or Nashorn).\n")
360-
(println "You can disable automatic browser launch with this REPL option")
361-
(println " :launch-browser false")
362-
(println "and you can specify the listen IP address with this REPL option")
363-
(println " :host \"127.0.0.1\"\n")
364-
(println (waiting-to-connect-message base-url)))))
365-
366-
(defn setup [{:keys [working-dir launch-browser server-state] :as repl-env} {:keys [output-dir] :as opts}]
352+
(defn- maybe-browse-url
353+
([base-url]
354+
(maybe-browse-url base-url false))
355+
([base-url new-window]
356+
(try
357+
(browse/browse-url
358+
(cond-> base-url
359+
new-window (str "?rel=" (System/currentTimeMillis))))
360+
(catch Throwable t
361+
(if-some [error-message (not-empty (.getMessage t))]
362+
(println "Failed to launch a browser:\n" error-message "\n")
363+
(println "Could not launch a browser.\n"))
364+
(println "You can instead launch a non-browser REPL (Node or Nashorn).\n")
365+
(println "You can disable automatic browser launch with this REPL option")
366+
(println " :launch-browser false")
367+
(println "and you can specify the listen IP address with this REPL option")
368+
(println " :host \"127.0.0.1\"\n")
369+
(println (waiting-to-connect-message base-url)))))
370+
)
371+
372+
(defn setup [{:keys [working-dir launch-browser new-window server-state] :as repl-env} {:keys [output-dir] :as opts}]
367373
(locking lock
368374
(when-not (:socket @server-state)
369375
(binding [browser-state (:browser-state repl-env)
@@ -391,7 +397,7 @@
391397
(server/start repl-env)
392398
(let [base-url (str "http://" (:host repl-env) ":" (:port repl-env))]
393399
(if launch-browser
394-
(maybe-browse-url base-url)
400+
(maybe-browse-url base-url new-window)
395401
(println (waiting-to-connect-message base-url)))))))
396402
(.put outs (thread-name) *out*)
397403
(swap! server-state update :listeners inc))
@@ -458,8 +464,9 @@
458464
{:host host
459465
:port port
460466
:launch-browser true
467+
:new-window false
461468
:working-dir (->> [".repl" (util/clojurescript-version)]
462-
(remove empty?) (string/join "-"))
469+
(remove empty?) (string/join "-"))
463470
:static-dir (cond-> ["." "out/"] output-dir (conj output-dir))
464471
:preloaded-libs []
465472
:src "src/"

0 commit comments

Comments
 (0)