Skip to content

Commit

Permalink
parsing tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 5, 2022
1 parent f277204 commit 14e1259
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/babashka/process.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,15 @@
maybe-prev (first args)
args (rest args)
[prev args] (if (or (instance? Process maybe-prev)
(instance? ProcessBuilder maybe-prev))
(instance? ProcessBuilder maybe-prev)
(and (nil? maybe-prev)
(sequential? (first args))))
[maybe-prev args]
[nil (cons maybe-prev args)])
;; we've parsed the input process, now assume the first argument is either an opts map, or a sequential
maybe-opts (first args)
args (rest args)
[opts args] (cond (map? maybe-opts)
[opts args] (cond (or (nil? maybe-opts) (map? maybe-opts))
[maybe-opts args args]
(sequential? maybe-opts)
;; flatten command structure
Expand Down
4 changes: 3 additions & 1 deletion test/babashka/process_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
(is (= {:out :string} (:opts norm))))
(testing "existing file invocation"
(let [args ["README.md" "a" "b" "c"]]
(is (= args (:cmd (p/parse-args args))))))))
(is (= args (:cmd (p/parse-args args))))))
(testing "prev may be nil"
(is (= ["echo" "hello"] (:cmd (p/parse-args [nil ["echo hello"]])))))))

(deftest process-test
(testing "By default process returns string out and err, returning the exit
Expand Down

0 comments on commit 14e1259

Please sign in to comment.