[#829] Allow thread-first in combination with shell
This commit is contained in:
parent
11b066ae70
commit
6aca41a48a
4 changed files with 20 additions and 5 deletions
2
process
2
process
|
|
@ -1 +1 @@
|
|||
Subproject commit eba04e6c35814296e5bb383804f801aee912cba1
|
||||
Subproject commit 3559a70686e435504b1bed320d2e513c5bf2bb15
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BABASHKA_FEATURE_JDBC=true
|
||||
BABASHKA_FEATURE_POSTGRESQL=true
|
||||
export BABASHKA_FEATURE_JDBC=true
|
||||
export BABASHKA_FEATURE_POSTGRESQL=true
|
||||
lein test :only babashka.postgresql-test
|
||||
|
|
|
|||
|
|
@ -61,7 +61,12 @@
|
|||
:shutdown p/destroy-tree})
|
||||
|
||||
(defn shell [cmd & args]
|
||||
(let [[opts cmd args]
|
||||
(let [[prev cmd args]
|
||||
(if (and (map? cmd)
|
||||
(:proc cmd))
|
||||
[cmd (first args) (rest args)]
|
||||
[nil cmd args])
|
||||
[opts cmd args]
|
||||
(if (map? cmd)
|
||||
[cmd (first args) (rest args)]
|
||||
[nil cmd args])
|
||||
|
|
@ -75,6 +80,9 @@
|
|||
(update opts :err io/file)
|
||||
opts)
|
||||
opts)
|
||||
opts (if prev
|
||||
(assoc opts :in nil)
|
||||
opts)
|
||||
cmd (if (.exists (io/file cmd))
|
||||
[cmd]
|
||||
(p/tokenize cmd))
|
||||
|
|
@ -82,7 +90,7 @@
|
|||
local-log-level (:log-level opts)]
|
||||
(sci/binding [log-level (or local-log-level @log-level)]
|
||||
(apply log-info cmd)
|
||||
(handle-non-zero (p/process cmd (merge default-opts opts)) opts))))
|
||||
(handle-non-zero (p/process prev cmd (merge default-opts opts)) opts))))
|
||||
|
||||
(defn clojure [cmd & args]
|
||||
(let [[opts cmd args]
|
||||
|
|
|
|||
|
|
@ -196,6 +196,13 @@
|
|||
(test-utils/with-config '{:tasks {b (System/getProperty "babashka.task")}}
|
||||
(let [s (bb "run" "--prn" "b")]
|
||||
(is (= "b" s)))))
|
||||
(testing "shell pipe test"
|
||||
(test-utils/with-config '{:tasks {a (-> (shell {:out :string}
|
||||
"echo hello")
|
||||
(shell {:out :string} "cat")
|
||||
:out)}}
|
||||
(let [s (bb "run" "--prn" "a")]
|
||||
(is (= "hello\n" s)))))
|
||||
|
||||
(deftest list-tasks-test
|
||||
(test-utils/with-config {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue