File tree 1 file changed +13
-8
lines changed
src/lambdaisland/launchpad
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 21
21
(defn canonical-path [p]
22
22
(.getCanonicalPath (io/file p)))
23
23
24
- (defn parent-path [p]
25
- (.getParent (io/file (canonical-path p))))
24
+ (defn dir-path [p]
25
+ (if (.isDirectory (io/file p))
26
+ (canonical-path p)
27
+ (.getParent (io/file (canonical-path p)))))
26
28
27
29
(require 'clojure.pprint)
28
30
53
55
[file->handler]
54
56
(let [file->handler (swap! handlers merge file->handler)
55
57
file->handler (update-keys file->handler canonical-path)
56
- directories (distinct (map parent -path (keys file->handler)))
58
+ directories (distinct (map dir -path (keys file->handler)))
57
59
; ; in case of nested directories, only watch the top-most one
58
60
directories (remove (fn [d]
59
61
(some #(and (not= d %)
67
69
(for [dir directories]
68
70
(watch
69
71
(fn [{:keys [type path] :as event}]
70
- (if-let [f (get file->handler (str path))]
71
- (try
72
- (f event)
73
- (catch Exception e
74
- (prn e)))))
72
+ (loop [path path]
73
+ (if-let [f (get file->handler (str path))]
74
+ (try
75
+ (f event)
76
+ (catch Exception e
77
+ (prn e)))
78
+ (when-let [p (.getParent path)]
79
+ (recur p)))))
75
80
(str dir))))))))
76
81
77
82
(comment
You can’t perform that action at this time.
0 commit comments