Skip to content

Commit

Permalink
concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Oct 19, 2024
1 parent 35d979e commit 976cdf2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/babashka/process.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,20 @@
:clj
(when (contains? (loaded-libs) 'clojure.pprint) ;; pprint was already loaded, e.g. by nREPL
(require '[babashka.process.pprint])))

(defn concurrently
([commands] (concurrently nil commands))
([_opts commands]
(let [counter (atom -1)
proc-fn (fn [command]
(let [id (swap! counter inc)]
(prn "command" command)
(apply process
{:out-line-fn (fn [line]
(println (format "[%s]" id) line))
:err-line-fn (fn [line]
(println (format "[%s]" id) line))}
command)))
procs (map proc-fn commands)]
(doseq [p procs]
(check p)))))

0 comments on commit 976cdf2

Please sign in to comment.