(defn namespace-exists?
"check that a namespace has been loaded"
[str-val]
(-> str-val
symbol
find-ns
nil?
not))
(defn file-path->str-namespace
"replace slashes with dots"
[file-path]
(-> file-path
(subs 1)
(clojure.string/replace #"/" ".")))
(defn load-and-check
"file located at src/<file-path>. <file-path> is a string"
[file-path]
(let [file-namespace (file-path->str-namespace file-path)]
(load file-path)
(namespace-exists? file-namespace))
;; Assuming `random-file.clj` is in src/
(load-and-check "random-file.clj")
Last active
November 23, 2019 16:35
-
-
Save ivermac/dd25bc4fe9297c337d384183d968ca3e to your computer and use it in GitHub Desktop.
Load and check if a namespace exists
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment