Skip to content

Commit 0809bf0

Browse files
committed
Preserve *ns* during build!, fixes #506
1 parent 051e4f2 commit 0809bf0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Changes can be:
5050

5151
* 🐜 Ensure custom `print-method` supporting unreadable symbols preserves metadata
5252

53+
* 🐞 Preserve `*ns*` during `build!`, fixes [#506](https://github.com/nextjournal/clerk/issues/506)
54+
5355
## 0.13.842 (2023-03-07)
5456

5557
* 💫 Support pagination for values nested inside `clerk/html`

src/nextjournal/clerk/builder.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@
389389
(report-fn {:stage :building :doc doc :idx idx})
390390
(let [{result :result duration :time-ms} (eval/time-ms
391391
(try
392-
(binding [*build-opts* opts
392+
(binding [*ns* *ns*
393+
*build-opts* opts
393394
viewer/doc-url (partial doc-url opts state file)]
394395
(let [doc (eval/eval-analyzed-doc doc)]
395396
(assoc doc :viewer (view/doc->viewer (assoc opts :static-build? true

test/nextjournal/clerk/builder_test.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
(is (= (#'builder/path-to-url-canonicalize dice) (str/replace dice (File/separator) "/"))))))
1515

1616
(deftest static-app
17-
(let [url* (volatile! nil)]
17+
(let [url* (volatile! nil)
18+
original-*ns* *ns*]
1819
(with-redefs [clojure.java.browse/browse-url (fn [path]
1920
(vreset! url* path))]
2021
(testing "browser receives canonical url in this system arch"
@@ -24,7 +25,10 @@
2425
(builder/build-static-app! {:browse? true
2526
:paths ["notebooks/hello.clj"]
2627
:out-path temp})
27-
(is (= expected @url*))))))))
28+
(is (= expected @url*)))))
29+
30+
(testing "*ns* isn't changed (#506)"
31+
(is (= original-*ns* *ns*))))))
2832

2933
(def test-paths ["boo*.clj"])
3034
(def test-paths-fn (fn [] ["boo*.clj"]))

0 commit comments

Comments
 (0)