Skip to content

Commit

Permalink
Fix beholder watch functionality. Improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ire committed Aug 12, 2024
1 parent 49e98ed commit a3cb965
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Fixed

- Fix beholder watch functionality that would cause a NullPointerException earlier.

## Changed

# 1.91.1392 (2024-05-23 / c2d7e1f)
Expand Down
4 changes: 3 additions & 1 deletion doc/07_watch_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ interface, the provided links describes how they work in detail.

``` clojure
#kaocha/v1
{:kaocha.watch/ignore ["*.tmp"]}
{:kaocha.watch/ignore ["**.tmp"]}
; this will match all files ending in .tmp in the current directory and
; any subdirectory
```

When running in watch mode you can press the Enter (Return) key to manually
Expand Down
6 changes: 4 additions & 2 deletions src/kaocha/watch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[lambdaisland.tools.namespace.track :as ctn-track]
[slingshot.slingshot :refer [try+]]
[nextjournal.beholder :as beholder])
(:import (java.nio.file FileSystems)
(:import (java.nio.file FileSystems Path)
(java.util.concurrent ArrayBlockingQueue BlockingQueue)))

(defn make-queue []
Expand Down Expand Up @@ -93,6 +93,7 @@
for a description of the patterns, these are similar but not the same as
typical shell glob patterns."
[path patterns]
(assert (instance? Path path))
(let [fs (FileSystems/getDefault)
patterns (map #(.getPathMatcher fs (str "glob:" %)) patterns)]
(some #(.matches % path) patterns)))
Expand Down Expand Up @@ -295,8 +296,9 @@ errors as test errors."
(defmethod watch! :beholder [{:keys [q watch-paths]}]
(apply beholder/watch
(fn [{:keys [type path]}]
(assert (instance? Path path))
(when (contains? #{:modify :create} type)
(qput q path)))
(qput q (.toFile path))))
(map str watch-paths)))

(defn run* [config finish? q]
Expand Down

0 comments on commit a3cb965

Please sign in to comment.