Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
Call (shutdown-agents) in slam.hound/-main
Browse files Browse the repository at this point in the history
Now that swap-in-reconstructed-ns-form can be passed a simple string, we
can reserve -main for command line use only.

Closes #75
  • Loading branch information
guns committed Mar 28, 2014
1 parent a005cdc commit 35897bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -81,7 +81,7 @@ You can reconstruct namespaces from a repl to avoid the slow startup time:

Or to reconstruct files in place:

user=> (slam.hound/-main "src/my/namespace.clj")
user=> (slam.hound/swap-in-reconstructed-ns-form "src/my/namespace.clj")
nil
;; Reload the file in your editor to pick up changes

Expand Down
9 changes: 7 additions & 2 deletions src/slam/hound.clj
Expand Up @@ -64,8 +64,11 @@
(finally
(.delete tmp-file)))))

(def ^:private ^:dynamic *testing?* false)

(defn -main
"Takes a file or dir and rewrites the .clj files with reconstructed ns forms."
"Takes a file or dir and rewrites the .clj files with reconstructed ns forms.
This function is strictly intended for use from a command line."
[& file-or-dirs]
(with-regrow-cache
(doseq [file-or-dir file-or-dirs
Expand All @@ -81,7 +84,9 @@
(println "Failed to reconstruct:" file)
(if (System/getenv "DEBUG")
(.printStackTrace e)
(println (.getMessage e))))))))
(println (.getMessage e)))))))
(when-not *testing?*
(shutdown-agents)))

;; See https://github.com/technomancy/nrepl-discover
(defn ^{:nrepl/op {:name "slam"
Expand Down
3 changes: 2 additions & 1 deletion test/slam/hound_test.clj
Expand Up @@ -155,6 +155,7 @@
(deftest ^:integration test-main
(with-tempfile tmp
(io/copy (io/reader (io/resource "test_namespace.clj")) tmp)
(-main tmp)
(binding [slam.hound/*testing?* true]
(-main tmp))
(is (= (slurp (io/resource "reconstructed_namespace.clj"))
(slurp tmp)))))

0 comments on commit 35897bc

Please sign in to comment.