Skip to content

Commit 5f25d2d

Browse files
committed
Improve watcher, hide clojure invocation
1 parent 47cb862 commit 5f25d2d

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Unreleased
22

3-
## Added
4-
5-
## Fixed
6-
73
## Changed
84

5+
- Merge consecutive calls to `lambdaisland.launchpad.watcher/watch!`, so it's
6+
easier to use from user code
7+
- Don't show full clojure invocation by default, can be seen with `--verbose`
8+
99
# 0.26.123-alpha (2024-01-29 / d471611)
1010

1111
## Fixed
@@ -209,4 +209,4 @@ Initial release
209209
- lambdaisland.classpath integration
210210
- Support for cider-nrepl, refactor-nrepl
211211
- Basic support for shadow-cljs cljs nREPL-base REPL
212-
- Auto-connect for Emacs
212+
- Auto-connect for Emacs

src/lambdaisland/launchpad.clj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,10 @@
494494

495495
(defn run-process [{:keys [cmd prefix working-dir
496496
background? timeout-ms check-exit-code? env
497-
color]
497+
color show-command?]
498498
:or {working-dir "."
499-
check-exit-code? true}}]
499+
check-exit-code? true
500+
show-command? true}}]
500501
(fn [ctx]
501502
(let [working-dir (io/file working-dir)
502503
proc-builder (doto (ProcessBuilder. (map str cmd))
@@ -506,7 +507,8 @@
506507
prefix (str "[" (ansi-fg (+ 30 color) (or prefix (first cmd))) "] ")
507508
process (pipe-process-output (.start proc-builder) prefix)
508509
ctx (update ctx :processes (fnil conj []) process)]
509-
(apply println (str prefix "$") (map shellquote cmd))
510+
(when show-command?
511+
(apply println (str prefix "$") (map shellquote cmd)))
510512
(if background?
511513
ctx
512514
(let [exit (if timeout-ms
@@ -523,7 +525,8 @@
523525
(apply debug (map shellquote args))
524526
((run-process {:cmd args
525527
:ctx-process-key :clojure-process
526-
:background? true}) ctx)))
528+
:background? true
529+
:show-command? false}) ctx)))
527530

528531
(def before-steps [read-deps-edn
529532
handle-cli-args

src/lambdaisland/launchpad/watcher.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
java.io.File
1616
io.methvin.watcher.DirectoryWatcher))
1717

18+
(defonce handlers (atom nil))
1819
(defonce watchers (atom nil))
1920

2021
(defn canonical-path [p]
@@ -50,7 +51,8 @@
5051
"Watch a number of files, takes a map from filename (string) to
5152
handler (receives a map with `:type` and `:path`, as with Beholder)."
5253
[file->handler]
53-
(let [file->handler (update-keys file->handler canonical-path)
54+
(let [file->handler (swap! handlers merge file->handler)
55+
file->handler (update-keys file->handler canonical-path)
5456
directories (distinct (map parent-path (keys file->handler)))
5557
;; in case of nested directories, only watch the top-most one
5658
directories (remove (fn [d]

0 commit comments

Comments
 (0)