-
Notifications
You must be signed in to change notification settings - Fork 26
/
bb.edn
28 lines (28 loc) · 1.28 KB
/
bb.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{:paths ["scripts"
"scripts-test"]
:tasks
{:requires ([babashka.fs :as fs]
[babashka.process :as p :refer [process]]
[babashka.wait :as wait])
;; bb nrepl
nrepl (let [paths ["scripts"
"scripts-test"]
proc (process (str "bb --nrepl-server " 0) {:err :inherit})]
(with-open [rdr (clojure.java.io/reader (:out proc))]
(binding [*in* rdr]
(loop [port nil]
(let [line (doto (read-line) println)
sentinel (Object.)]
(when (= sentinel (deref proc 1 sentinel))
(if port
(recur port)
(if-some [port (some->> line
(re-matches (re-pattern "Started nREPL server at 127.0.0.1:(\\d+)"))
second)]
(do (assert (Integer/parseInt port))
(doseq [path paths
:let [nrepl-port-path (str path "/.nrepl-port")]]
(spit nrepl-port-path port)
(fs/delete-on-exit nrepl-port-path))
(recur port))
(recur port)))))))))}}