Skip to content

Commit 45a1129

Browse files
mkphilippamarkovics
authored andcommitted
Don't run existing files through fs/glob (#519)
Fixes #504. Also improves performance of homepage.
1 parent 8dd37db commit 45a1129

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ Changes can be:
2020

2121
* 💫 Assign `:name` to every viewer in `default-viewers`
2222

23+
* 🐞 Don't run existing files through `fs/glob`, fixes [#504](https://github.com/nextjournal/clerk/issues/504). Also improves performance of homepage.
24+
2325
* 🐞 Show correct non-var return value for deflike form, fixes [#499](https://github.com/nextjournal/clerk/issues/499)
2426

27+
2528
## 0.14.919 (2023-06-13)
2629

2730
* 🚨 Breaking Changes:

src/nextjournal/clerk/builder.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@
185185
(if error
186186
opts
187187
(->> resolved-paths
188-
(mapcat (partial fs/glob "."))
188+
(mapcat (fn [path] (if (fs/exists? path)
189+
[path]
190+
(fs/glob "." path))))
189191
(filter (complement fs/directory?))
190192
(mapv (comp str fs/file))
191193
(hash-map :expanded-paths)
@@ -197,7 +199,7 @@
197199
#_(expand-paths {:index "book.clj"})
198200
#_(expand-paths {:paths-fn `clerk-docs})
199201
#_(expand-paths {:paths-fn `clerk-docs-2})
200-
#_(do (defn my-paths [] ["notebooks/h*.clj"])
202+
#_(do (defn my-paths [] ["notebooks/h*.clj"])§
201203
(expand-paths {:paths-fn `my-paths}))
202204
#_(expand-paths {:paths ["notebooks/viewers**"]})
203205

test/nextjournal/clerk/builder_test.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
(builder/expand-paths {:paths ["notebooks/rule_**.clj"]
5959
:index (str (fs/file "notebooks" "rule_30.clj"))}))))
6060

61+
(testing "supports absolute paths (#504)"
62+
(is (= {:expanded-paths [(str (fs/file (fs/cwd) "book.clj"))]}
63+
(builder/expand-paths {:paths [(str (fs/file (fs/cwd) "book.clj"))]}))))
64+
6165
(testing "invalid args"
6266
(is (match? {:error #"must set either"}
6367
(builder/expand-paths {})))

0 commit comments

Comments
 (0)