Support new syntax in babashka.deps/clojure (#1440)
This commit is contained in:
parent
cd3252796e
commit
69db7105e5
2 changed files with 33 additions and 22 deletions
|
|
@ -27,25 +27,28 @@
|
||||||
|
|
||||||
(-> @(clojure) :exit) starts a clojure REPL, waits for it
|
(-> @(clojure) :exit) starts a clojure REPL, waits for it
|
||||||
to finish and returns the exit code from the process."
|
to finish and returns the exit code from the process."
|
||||||
([] (clojure []))
|
[& args]
|
||||||
([args] (clojure args nil))
|
(let [{:keys [cmd opts prev]} (p/parse-args args)
|
||||||
([args opts]
|
opts (merge {:in :inherit
|
||||||
(let [opts (merge {:in :inherit
|
:out :inherit
|
||||||
:out :inherit
|
:err :inherit
|
||||||
:err :inherit
|
:shutdown p/destroy-tree}
|
||||||
:shutdown p/destroy-tree}
|
opts)]
|
||||||
opts)]
|
(binding [*in* @sci/in
|
||||||
(binding [*in* @sci/in
|
*out* @sci/out
|
||||||
*out* @sci/out
|
*err* @sci/err
|
||||||
*err* @sci/err
|
deps/*dir* (:dir opts)
|
||||||
deps/*dir* (:dir opts)
|
deps/*env* (:env opts)
|
||||||
deps/*env* (:env opts)
|
deps/*extra-env* (:extra-env opts)
|
||||||
deps/*extra-env* (:extra-env opts)
|
deps/*process-fn* (fn
|
||||||
deps/*process-fn* (fn
|
([cmd] (pp/process* {:cmd cmd
|
||||||
([cmd] (pp/process cmd opts))
|
:prev prev
|
||||||
([cmd _] (pp/process cmd opts)))
|
:opts opts}))
|
||||||
deps/*exit-fn* (fn
|
([cmd _] (pp/process* {:cmd cmd
|
||||||
([_])
|
:prev prev
|
||||||
([_exit-code msg]
|
:opts opts})))
|
||||||
(throw (Exception. msg))))]
|
deps/*exit-fn* (fn
|
||||||
(apply deps/-main (map str args))))))
|
([_])
|
||||||
|
([_exit-code msg]
|
||||||
|
(throw (Exception. msg))))]
|
||||||
|
(apply deps/-main cmd))))
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,14 @@ true
|
||||||
(-> (babashka.deps/clojure [\"-M\" \"-e\" \"(+ 1 2 3)\"] {:out :string})
|
(-> (babashka.deps/clojure [\"-M\" \"-e\" \"(+ 1 2 3)\"] {:out :string})
|
||||||
(p/check)
|
(p/check)
|
||||||
:out)
|
:out)
|
||||||
|
"))))
|
||||||
|
(is (= "6\n" (test-utils/normalize (bb "
|
||||||
|
(require '[babashka.deps :as deps])
|
||||||
|
(require '[babashka.process :as p])
|
||||||
|
|
||||||
|
(-> (babashka.deps/clojure {:out :string} \"-M\" \"-e\" \"(+ 1 2 3)\")
|
||||||
|
(p/check)
|
||||||
|
:out)
|
||||||
"))))
|
"))))
|
||||||
(when-not test-utils/native?
|
(when-not test-utils/native?
|
||||||
(is (thrown-with-msg? Exception #"Option changed" (bb "
|
(is (thrown-with-msg? Exception #"Option changed" (bb "
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue