Skip to content

Commit 0c8a675

Browse files
authored
Merge pull request #10 from lambdaisland/ox/optional-shadow-ids-to-connect
✨ Allow connection to specific shadow-ids
2 parents 4b62dab + 84c4243 commit 0c8a675

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ configure launchpad.
125125
:launchpad/shadow-build-ids [] ; which shadow builds to start, although it may
126126
; be preferable to configure this as part of
127127
; specific aliases in your main deps.edn
128+
;; which shadow builds to automatically connect to if `--emacs` flag is provided
129+
:launchpad/shadow-connect-ids []
128130
}
129131
```
130132

src/lambdaisland/launchpad.clj

+12-4
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,22 @@
320320
(let [build-ids (->> aliases
321321
(mapcat #(get-in deps-edn [:aliases % :launchpad/shadow-build-ids]))
322322
(concat (:launchpad/shadow-build-ids deps-edn))
323-
distinct)]
323+
distinct)
324+
connect-ids (->> aliases
325+
(mapcat #(get-in deps-edn [:aliases % :launchpad/shadow-connect-ids]))
326+
(concat (:launchpad/shadow-connect-ids deps-edn))
327+
distinct)
328+
connect-ids (if (empty? connect-ids)
329+
build-ids
330+
connect-ids)]
324331
;; FIXME filter this down to builds that exist in the combined shadow config
325332
(when (seq build-ids)
326333
(debug "Starting shadow-cljs builds" build-ids))
327334
(if (seq build-ids)
328335
(-> ctx
329336
(update :middleware (fnil conj []) 'shadow.cljs.devtools.server.nrepl/middleware)
330337
(assoc :shadow-cljs/build-ids build-ids)
338+
(assoc :shadow-cljs/connect-ids connect-ids)
331339
(update :eval-forms (fnil conj [])
332340
'(require 'lambdaisland.launchpad.shadow)
333341
`(apply
@@ -361,13 +369,13 @@
361369
:port ~nrepl-port
362370
:project-dir ~project-root))))
363371

364-
~@(for [build-id (:shadow-cljs/build-ids ctx)
365-
:let [init-sym (symbol "launchpad" (name build-id))]]
372+
~@(for [connect-id (:shadow-cljs/connect-ids ctx)
373+
:let [init-sym (symbol "launchpad" (name connect-id))]]
366374
`(~'progn
367375
(~'setf (~'alist-get '~init-sym
368376
~'cider-cljs-repl-types)
369377
(~'list ~(pr-str
370-
`(shadow.cljs.devtools.api/nrepl-select ~build-id))))
378+
`(shadow.cljs.devtools.api/nrepl-select ~connect-id))))
371379
(~'cider-connect-sibling-cljs (~'list
372380
:cljs-repl-type '~init-sym
373381
:host "localhost"

0 commit comments

Comments
 (0)