wip
This commit is contained in:
parent
200caef226
commit
5b9e3c3267
2 changed files with 23 additions and 4 deletions
|
|
@ -481,8 +481,10 @@ Use -- to separate script command line args from bb command line args.
|
|||
(assoc opts-map :main (first options))))
|
||||
(":do")
|
||||
(let [options (next options)
|
||||
options (into [] (comp (partition-by #(or (= % ":and-do")
|
||||
(= % ":or-do"))))
|
||||
options (into [] (comp (partition-by #(or
|
||||
(= % ":do")
|
||||
(= % ":and-do")
|
||||
(= % ":or-do"))))
|
||||
options)]
|
||||
{:do options})
|
||||
(":invoke")
|
||||
|
|
@ -738,13 +740,15 @@ Use -- to separate script command line args from bb command line args.
|
|||
(let [opts (parse-opts args)]
|
||||
(if-let [do-opts (:do opts)]
|
||||
(reduce (fn [prev-exit opts]
|
||||
;; (prn :prev prev-exit)
|
||||
;; (prn :opts opts)
|
||||
(if (pos? prev-exit)
|
||||
(case opts
|
||||
[":or-do"] 0
|
||||
([":do"] [":or-do"]) 0 ;; skipping, returning 0
|
||||
(reduced prev-exit))
|
||||
(case opts
|
||||
[":or-do"] (reduced prev-exit) ;; short-cutting
|
||||
[":and-do"] 0 ;; skipping, returning 0
|
||||
([":do"] [":and-do"]) 0 ;; skipping, returning 0
|
||||
(exec (parse-opts opts)))))
|
||||
0
|
||||
do-opts)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,21 @@
|
|||
(let [res (bb :all)]
|
||||
(is (= 6 res)))
|
||||
(is (not (fs/exists? temp-file))))))
|
||||
(testing ":do always continuing"
|
||||
(with-config {:tasks {:sum-1 {:task/type :babashka
|
||||
:args ["-e" "(do (+ 4 5 6) nil)"]}
|
||||
:sum-2 {:task/type :babashka
|
||||
:args ["-e" "(+ 1 2 3)"]}
|
||||
:all {:task/type :babashka
|
||||
:args [:do :sum-1 :do :sum-2]}}}
|
||||
(is (= 6 (bb :all))))
|
||||
(with-config {:tasks {:div-by-zero {:task/type :babashka
|
||||
:args ["-e" "(/ 1 0)"]}
|
||||
:sum {:task/type :babashka
|
||||
:args ["-e" "(+ 1 2 3)"]}
|
||||
:all {:task/type :babashka
|
||||
:args [:do :div-by-zero :do :sum]}}}
|
||||
(is (= 6 (bb :all)))))
|
||||
(testing ":and-do failing"
|
||||
(with-config {:tasks {:div-by-zero {:task/type :babashka
|
||||
:args ["-e" "(/ 1 0)"]}
|
||||
|
|
|
|||
Loading…
Reference in a new issue