22
22
[lambdaisland.tools.namespace.track :as ctn-track]
23
23
[slingshot.slingshot :refer [try+]]
24
24
[nextjournal.beholder :as beholder])
25
- (:import (java.nio.file FileSystems)
25
+ (:import (java.io File)
26
+ (java.nio.file FileSystems Path PathMatcher)
26
27
(java.util.concurrent ArrayBlockingQueue BlockingQueue)))
27
28
28
29
(defn make-queue []
93
94
for a description of the patterns, these are similar but not the same as
94
95
typical shell glob patterns."
95
96
[path patterns]
97
+ (assert (instance? Path path))
96
98
(let [fs (FileSystems/getDefault )
97
99
patterns (map #(.getPathMatcher fs (str " glob:" %)) patterns)]
98
- (some #(.matches % path) patterns)))
100
+ (some #(.matches ^PathMatcher % path) patterns)))
99
101
100
102
(defn convert
101
103
" Converts a Git-style ignore pattern into the equivalent pattern that Java PathMatcher uses."
153
155
" Finds ignore files in the local directory and the system."
154
156
[dir]
155
157
(let [absolute-files [(io/file (str (System/getProperty " user.home" ) " /.config/git/ignore" ))]
156
- relative-files (filter #(glob? (.toPath %) [" **.gitignore" " **.ignore" ]) (file-seq (io/file dir)))]
158
+ relative-files (filter #(glob? (.toPath ^File %) [" **.gitignore" " **.ignore" ]) (file-seq (io/file dir)))]
157
159
(into absolute-files relative-files)))
158
160
159
161
(defn merge-ignore-files
169
171
(defn wait-and-rescan! [q tracker watch-paths ignore]
170
172
(let [f (qtake q)]
171
173
(cond
172
- (and (file? f) (glob? (.toPath f) ignore))
174
+ (and (file? f) (glob? (.toPath ^File f) ignore))
173
175
(recur q tracker watch-paths ignore)
174
176
175
177
(directory? f)
@@ -281,7 +283,7 @@ errors as test errors."
281
283
(map io/file))
282
284
(:kaocha/tests config))
283
285
; ; Without this, if any path doesn't exist the watching doesn't work.
284
- (filter (fn [x] (.exists ^java.io. File x)))))
286
+ (filter (fn [x] (.exists ^File x)))))
285
287
286
288
(defmulti watch! :type )
287
289
@@ -295,8 +297,9 @@ errors as test errors."
295
297
(defmethod watch! :beholder [{:keys [q watch-paths]}]
296
298
(apply beholder/watch
297
299
(fn [{:keys [type path]}]
300
+ (assert (instance? Path path))
298
301
(when (contains? #{:modify :create } type)
299
- (qput q path)))
302
+ (qput q ( .toFile ^Path path) )))
300
303
(map str watch-paths)))
301
304
302
305
(defn run* [config finish? q]
@@ -307,7 +310,7 @@ errors as test errors."
307
310
{})
308
311
watch-paths (if (:kaocha.watch/use-ignore-file config)
309
312
(set/union (watch-paths config)
310
- (set (map #(.getParentFile (.getCanonicalFile %)) (find-ignore-files " ." ))))
313
+ (set (map #(.getParentFile (.getCanonicalFile ^File %)) (find-ignore-files " ." ))))
311
314
(watch-paths config))
312
315
tracker (ctn-track/tracker )
313
316
; ; if t.n fails due to circular dependencies, do not track-reload.
0 commit comments