do
This commit is contained in:
parent
c2829fe34d
commit
a3f7cebd15
2 changed files with 10 additions and 18 deletions
|
|
@ -411,19 +411,17 @@ Use -- to separate script command line args from bb command line args.
|
||||||
key? (when fst (str/starts-with? fst ":"))
|
key? (when fst (str/starts-with? fst ":"))
|
||||||
keys (when key? (rest (str/split fst #":")))
|
keys (when key? (rest (str/split fst #":")))
|
||||||
expanded (when (and key? (> (count keys) 1))
|
expanded (when (and key? (> (count keys) 1))
|
||||||
(concat (cons ":do" (interpose ":and-do"
|
(into [:do] (map (comp vector keyword) keys)))
|
||||||
(map #(str ":" %)
|
|
||||||
keys)))
|
|
||||||
(rest options)))
|
|
||||||
k (when (and key? (not expanded))
|
k (when (and key? (not expanded))
|
||||||
(keyword (first keys)))
|
(keyword (first keys)))
|
||||||
bb-edn (when k @bb-edn)
|
task? (or expanded k)
|
||||||
tasks (when (and k bb-edn)
|
bb-edn (when task? @bb-edn)
|
||||||
|
tasks (when (and task? bb-edn)
|
||||||
(:tasks bb-edn))
|
(:tasks bb-edn))
|
||||||
user-task (when tasks (get tasks k))]
|
user-task (when tasks (get tasks k))]
|
||||||
(cond user-task
|
(cond user-task
|
||||||
(resolve-task tasks user-task {:command-line-args (next options)})
|
(resolve-task tasks user-task {:command-line-args (next options)})
|
||||||
expanded (parse-opts expanded)
|
expanded (resolve-task tasks expanded nil)
|
||||||
:else
|
:else
|
||||||
(let [opts (loop [options options
|
(let [opts (loop [options options
|
||||||
opts-map {}]
|
opts-map {}]
|
||||||
|
|
@ -818,18 +816,12 @@ Use -- to separate script command line args from bb command line args.
|
||||||
(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)]
|
(if-let [do-opts (:do opts)]
|
||||||
(reduce (fn [_prev-exit opts]
|
(reduce (fn [prev-exit opts]
|
||||||
;; (prn :prev prev-exit)
|
;; (prn :prev prev-exit)
|
||||||
;; (prn :opts opts)
|
;; (prn :opts opts)
|
||||||
(exec opts)
|
(if (pos? prev-exit)
|
||||||
#_(if (pos? prev-exit)
|
(reduced prev-exit)
|
||||||
(case opts
|
(exec opts)))
|
||||||
([":do"] [":or-do"]) 0 ;; skipping, returning 0
|
|
||||||
(reduced prev-exit))
|
|
||||||
(case opts
|
|
||||||
[":or-do"] (reduced prev-exit) ;; short-cutting
|
|
||||||
([":do"] [":and-do"]) 0 ;; skipping, returning 0
|
|
||||||
(exec (parse-opts opts)))))
|
|
||||||
0
|
0
|
||||||
do-opts)
|
do-opts)
|
||||||
(exec opts))))
|
(exec opts))))
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
:sum [:babashka "-e" "(+ 1 2 3)"]
|
:sum [:babashka "-e" "(+ 1 2 3)"]
|
||||||
:all[:babashka :div-by-zero:sum] }}
|
:all[:babashka :div-by-zero:sum] }}
|
||||||
(is (= 6 (bb :all)))))
|
(is (= 6 (bb :all)))))
|
||||||
#_(testing ":and-do failing"
|
(testing "task fails when one of subtask fails"
|
||||||
(with-config {:tasks {:div-by-zero [:babashka "-e" "(/ 1 0)"]
|
(with-config {:tasks {:div-by-zero [:babashka "-e" "(/ 1 0)"]
|
||||||
:sum [:babashka "-e" "(+ 1 2 3)"]
|
:sum [:babashka "-e" "(+ 1 2 3)"]
|
||||||
:all [:babashka :div-by-zero:sum]}}
|
:all [:babashka :div-by-zero:sum]}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue