From d68c9397599366777d9b322ec586fdd398302f25 Mon Sep 17 00:00:00 2001 From: Mike Fikes Date: Fri, 4 May 2018 17:01:33 -0400 Subject: [PATCH] cljs.repl/add-lib --- src/main/clojure/cljs/cli.clj | 2 ++ src/main/clojure/cljs/repl.cljc | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/clojure/cljs/cli.clj b/src/main/clojure/cljs/cli.clj index 677dcdd948..174df3af7e 100644 --- a/src/main/clojure/cljs/cli.clj +++ b/src/main/clojure/cljs/cli.clj @@ -608,6 +608,8 @@ present" sequence of command line flags." [repl-env & args] (try + (let [cl (.getContextClassLoader (Thread/currentThread))] + (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl))) (let [commands (merged-commands repl-env)] (if args (loop [[opt arg & more :as args] (normalize commands args) inits []] diff --git a/src/main/clojure/cljs/repl.cljc b/src/main/clojure/cljs/repl.cljc index 94c7799bb5..af0843a12f 100644 --- a/src/main/clojure/cljs/repl.cljc +++ b/src/main/clojure/cljs/repl.cljc @@ -1371,3 +1371,13 @@ str-or-pattern." (-parse-error repl-env ret *repl-opts*) ret) nil *repl-opts*)))))) + +(defmacro add-lib + [[quote lib] coord] + (try + (require 'clojure.tools.deps.alpha.repl) + (when-let [add-lib (resolve 'clojure.tools.deps.alpha.repl/add-lib)] + (add-lib lib coord)) + (catch Exception e + (.printStackTrace e) + nil)))