diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a55f26..e890c4bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## Fixed - Fix beholder watch functionality that would cause a NullPointerException earlier. +- `*.` will now match files with `.ext` extensions in any directory. ## Changed diff --git a/src/kaocha/watch.clj b/src/kaocha/watch.clj index 35a9f44d..0412ac83 100644 --- a/src/kaocha/watch.clj +++ b/src/kaocha/watch.clj @@ -87,6 +87,17 @@ (assoc tracker ::tracker-error e) (throw e))))) +(defn- fix-pattern + "beholder, the file change watcher, will always produce fully qualified paths. + A '*.' pattern will never match anything. + Such a pattern will be prefixed with '*'. + This will cause the pattern to match all files ending in '.' in any directory." + [pattern] + (assert (string? pattern)) + (if (str/starts-with? pattern "*.") + (str "*" pattern) + pattern)) + (defn glob? "Does path match any of the glob patterns. @@ -96,7 +107,7 @@ [path patterns] (assert (instance? Path path)) (let [fs (FileSystems/getDefault) - patterns (map #(.getPathMatcher fs (str "glob:" %)) patterns)] + patterns (map #(.getPathMatcher fs (str "glob:" (fix-pattern %))) patterns)] (some #(.matches ^PathMatcher % path) patterns))) (defn convert