Support new syntax in babashka.deps/clojure (#1440)

This commit is contained in:
Michiel Borkent 2022-12-07 10:04:40 +01:00 committed by GitHub
parent cd3252796e
commit 69db7105e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 22 deletions

View file

@ -27,10 +27,9 @@
(-> @(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}
@ -42,10 +41,14 @@
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 opts)) ([cmd] (pp/process* {:cmd cmd
([cmd _] (pp/process cmd opts))) :prev prev
:opts opts}))
([cmd _] (pp/process* {:cmd cmd
:prev prev
:opts opts})))
deps/*exit-fn* (fn deps/*exit-fn* (fn
([_]) ([_])
([_exit-code msg] ([_exit-code msg]
(throw (Exception. msg))))] (throw (Exception. msg))))]
(apply deps/-main (map str args)))))) (apply deps/-main cmd))))

View file

@ -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 "