Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dir and repl-opts to the cljs-task #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/adzerk/boot_cljs_repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

(def ^:private ws-settings (atom {}))
(def ^:private out-file (atom nil))
(def ^:private cljs-repl-opts (atom {}))

(def ^:private deps
'[[com.cemerick/piggieback "0.2.1" :scope "test"]
Expand Down Expand Up @@ -111,13 +112,16 @@
:ip str The IP address the websocket server will listen on.
:port int The port the websocket server will listen on.
:ws-host str Websocket host to connect to.
:secure bool Flag to indicate whether to use a secure websocket."
[& {i :ip p :port secure :secure ws-host :ws-host}]
:secure bool Flag to indicate whether to use a secure websocket.
:repl-opts map options passed to the cljs-repl"
[& {i :ip p :port secure :secure ws-host :ws-host repl-opts :repl-opts}]
(let [i (or i (:ws-ip @ws-settings))
p (or p (:ws-port @ws-settings) 0)
ws-host (or ws-host (:ws-host @ws-settings))
secure (or secure (:secure @ws-settings))]
((r cemerick.piggieback/cljs-repl) (repl-env :ip i :port p :ws-host ws-host :secure secure))))
(apply (r cemerick.piggieback/cljs-repl)
(repl-env :ip i :port p :ws-host ws-host :secure secure)
(mapcat identity (merge @cljs-repl-opts repl-opts)))))

(defn- add-init!
[in-file out-file]
Expand Down Expand Up @@ -149,7 +153,9 @@
n nrepl-opts NREPL_OPTS edn "Options passed to the `repl` task."
p port PORT int "The port the websocket server listens on."
w ws-host WSADDR str "The (optional) websocket host address to pass to clients."
s secure bool "Flag to indicate whether the client should connect via wss. Defaults to false."]
s secure bool "Flag to indicate whether the client should connect via wss. Defaults to false."
d dir DIR str "The output-dir for repl-compiled Javascript. Defaults to \"target/main.out\""
r repl-opts REPL_OPTS edn "Options passed to the cljs-repl"]
(let [src (b/tmp-dir!)
tmp (b/tmp-dir!)
prev (atom nil)
Expand All @@ -162,6 +168,8 @@
(when port (swap! ws-settings assoc :ws-port port))
(when ws-host (swap! ws-settings assoc :ws-host ws-host))
(when secure (swap! ws-settings assoc :secure secure))
(swap! cljs-repl-opts assoc :output-dir (or dir "target/main.out"))
(when repl-opts (swap! cljs-repl-opts merge repl-opts))
(reset! out-file (io/file src "adzerk" "boot_cljs_repl.cljs"))
(make-repl-connect-file nil)
(comp
Expand Down