fix do
This commit is contained in:
parent
5444ce43a6
commit
ed40991c56
2 changed files with 26 additions and 10 deletions
|
|
@ -844,6 +844,18 @@ Use -- to separate script command line args from bb command line args.
|
||||||
:verbose verbose?}))
|
:verbose verbose?}))
|
||||||
exit-code))))
|
exit-code))))
|
||||||
|
|
||||||
|
(defn exec* [opts]
|
||||||
|
(if-let [do-opts (:do opts)]
|
||||||
|
(reduce (fn [prev-exit opts]
|
||||||
|
;; (prn :prev prev-exit)
|
||||||
|
;; (prn :opts opts)
|
||||||
|
(if (pos? prev-exit)
|
||||||
|
(reduced prev-exit)
|
||||||
|
(exec* opts)))
|
||||||
|
0
|
||||||
|
do-opts)
|
||||||
|
(exec opts)))
|
||||||
|
|
||||||
(defn main [& args]
|
(defn main [& args]
|
||||||
(let [bb-edn-file (or (System/getenv "BABASHKA_EDN")
|
(let [bb-edn-file (or (System/getenv "BABASHKA_EDN")
|
||||||
"bb.edn")]
|
"bb.edn")]
|
||||||
|
|
@ -853,16 +865,7 @@ Use -- to separate script command line args from bb command line args.
|
||||||
;; we mutate the atom from tests as well, so despite the above it can contain a bb.edn
|
;; we mutate the atom from tests as well, so despite the above it can contain a bb.edn
|
||||||
(when-let [bb-edn @bb-edn] (deps/add-deps bb-edn)))
|
(when-let [bb-edn @bb-edn] (deps/add-deps bb-edn)))
|
||||||
(let [opts (parse-opts args)]
|
(let [opts (parse-opts args)]
|
||||||
(if-let [do-opts (:do opts)]
|
(exec* opts)))
|
||||||
(reduce (fn [prev-exit opts]
|
|
||||||
;; (prn :prev prev-exit)
|
|
||||||
;; (prn :opts opts)
|
|
||||||
(if (pos? prev-exit)
|
|
||||||
(reduced prev-exit)
|
|
||||||
(exec opts)))
|
|
||||||
0
|
|
||||||
do-opts)
|
|
||||||
(exec opts))))
|
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& args]
|
[& args]
|
||||||
|
|
|
||||||
|
|
@ -151,3 +151,16 @@ Addition is a pretty advanced topic. Let us start with the identity element
|
||||||
(let [res (apply test-utils/bb nil
|
(let [res (apply test-utils/bb nil
|
||||||
(map str ["doc" :main-task]))]
|
(map str ["doc" :main-task]))]
|
||||||
(is (str/includes? res "Usage: just pass some args")))))
|
(is (str/includes? res "Usage: just pass some args")))))
|
||||||
|
|
||||||
|
(deftest do-test
|
||||||
|
(let [temp-dir (fs/create-temp-dir)
|
||||||
|
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))]
|
||||||
|
(with-config {:tasks {:bye ['do
|
||||||
|
['babashka "-e" "(+ 1 2 3)"]
|
||||||
|
['shell "rm" (str temp-file)]]
|
||||||
|
:hello ['do
|
||||||
|
['babashka "-e" "(+ 1 2 3)"]
|
||||||
|
[:bye]]}}
|
||||||
|
(is (fs/exists? temp-file))
|
||||||
|
(bb :hello)
|
||||||
|
(is (not (fs/exists? temp-file))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue