|
60 | 60 | (deps-set ns))]
|
61 | 61 | file)))
|
62 | 62 |
|
63 |
| -(defn- in-refresh-dirs? [refresh-dirs file] |
| 63 | +(defn- absolutize-refresh-dirs [refresh-dirs] |
| 64 | + (->> refresh-dirs |
| 65 | + (map (fn [^String s] |
| 66 | + (File. s))) |
| 67 | + (filter (fn [^File f] |
| 68 | + (.exists f))) |
| 69 | + (map (fn [^File f] |
| 70 | + (let [v (.getCanonicalPath f)] |
| 71 | + (cond-> v |
| 72 | + (not (str/ends-with? v File/separator)) |
| 73 | + ;; add a trailing slash for a more robust comparison with `file-as-absolute-paths`: |
| 74 | + (str File/separator))))))) |
| 75 | + |
| 76 | +(defn in-refresh-dirs? |
| 77 | + "Is `filename` located within any of `refresh-dirs`?" |
| 78 | + [refresh-dirs refresh-dirs-as-absolute-paths filename] |
64 | 79 | (if-not (seq refresh-dirs)
|
65 | 80 | ;; the end user has not set the `refresh-dirs`, so this defn's logic should be bypassed:
|
66 | 81 | true
|
67 |
| - (let [file-as-absolute-paths (-> file io/file .getCanonicalPath) |
68 |
| - refresh-dirs-as-absolute-paths (->> refresh-dirs |
69 |
| - (map (fn [^String s] |
70 |
| - (File. s))) |
71 |
| - (filter (fn [^File f] |
72 |
| - (.exists f))) |
73 |
| - (map (fn [^File f] |
74 |
| - (let [v (.getCanonicalPath f)] |
75 |
| - (cond-> v |
76 |
| - (not (str/ends-with? v File/separator)) |
77 |
| - ;; add a trailing slash for a more robust comparison with `file-as-absolute-paths`: |
78 |
| - (str File/separator))))))] |
79 |
| - (boolean (some #(str/starts-with? % file-as-absolute-paths) |
80 |
| - refresh-dirs-as-absolute-paths))))) |
| 82 | + (let [file (-> filename io/file) |
| 83 | + file-as-absolute-path (-> file .getCanonicalPath)] |
| 84 | + (and (-> file .exists) |
| 85 | + (-> file .isFile) |
| 86 | + (boolean (some (partial str/starts-with? file-as-absolute-path) |
| 87 | + refresh-dirs-as-absolute-paths)))))) |
81 | 88 |
|
82 | 89 | (defn project-files-in-topo-order
|
83 | 90 | ([]
|
84 | 91 | (project-files-in-topo-order false))
|
85 | 92 | ([ignore-errors?]
|
86 | 93 | (let [tracker (build-tracker (util/with-suppressed-errors
|
87 |
| - (every-pred (partial in-refresh-dirs? (user-refresh-dirs)) |
| 94 | + (every-pred (partial in-refresh-dirs? refresh-dirs (absolutize-refresh-dirs user-refresh-dirs)) |
88 | 95 | core/clj-file?)
|
89 | 96 | ignore-errors?))
|
90 | 97 | nses (dep/topo-sort (:clojure.tools.namespace.track/deps tracker))
|
|
0 commit comments