Fix #1506: :exec-args in task should override :exec-args on fn metadata
This commit is contained in:
parent
3f4ac12cc4
commit
076a2774be
4 changed files with 17 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ A preview of the next release can be installed from
|
||||||
- [#1487](https://github.com/babashka/babashka/issues/1487): `babashka.tasks/clojure` should be supported without arguments to start a REPL
|
- [#1487](https://github.com/babashka/babashka/issues/1487): `babashka.tasks/clojure` should be supported without arguments to start a REPL
|
||||||
- [#1496](https://github.com/babashka/babashka/issues/1496): Add `set-agent-send-executor!` and `set-agent-send-off-executor!`
|
- [#1496](https://github.com/babashka/babashka/issues/1496): Add `set-agent-send-executor!` and `set-agent-send-off-executor!`
|
||||||
- [#1489](https://github.com/babashka/babashka/issues/1489): Don't overwrite non-empty, non-jar files when writing uberscript/uberjar ([@bobisageek](https://github.com/bobisageek))
|
- [#1489](https://github.com/babashka/babashka/issues/1489): Don't overwrite non-empty, non-jar files when writing uberscript/uberjar ([@bobisageek](https://github.com/bobisageek))
|
||||||
|
- [#1506](https://github.com/babashka/babashka/issues/1506): `:exec-args` in task should override `:exec-args` on fn metadata
|
||||||
|
|
||||||
## 1.1.173 (2023-02-04)
|
## 1.1.173 (2023-02-04)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,16 @@
|
||||||
ns (:ns (meta the-var))
|
ns (:ns (meta the-var))
|
||||||
ns-meta (meta ns)
|
ns-meta (meta ns)
|
||||||
ct (babashka.tasks/current-task)
|
ct (babashka.tasks/current-task)
|
||||||
|
exec-args (babashka.cli/merge-opts (:exec-args (:org.babashka/cli ns-meta))
|
||||||
|
(:exec-args (:org.babashka/cli the-var-meta))
|
||||||
|
(:exec-args (:org.babashka/cli ct))
|
||||||
|
(:exec-args ct)
|
||||||
|
(:exec-args extra-opts))
|
||||||
cli-opts (babashka.cli/merge-opts (:org.babashka/cli ns-meta)
|
cli-opts (babashka.cli/merge-opts (:org.babashka/cli ns-meta)
|
||||||
(:org.babashka/cli the-var-meta)
|
(:org.babashka/cli the-var-meta)
|
||||||
(:org.babashka/cli ct)
|
(:org.babashka/cli ct)
|
||||||
extra-opts)
|
extra-opts)
|
||||||
task-exec-args (:exec-args ct)
|
cli-opts (assoc cli-opts :exec-args exec-args)
|
||||||
cli-exec-args (:exec-args cli-opts)
|
|
||||||
exec-args {:exec-args (babashka.cli/merge-opts cli-exec-args task-exec-args)}
|
|
||||||
cli-opts (babashka.cli/merge-opts exec-args cli-opts)
|
|
||||||
opts (babashka.cli/parse-opts *command-line-args* cli-opts)]
|
opts (babashka.cli/parse-opts *command-line-args* cli-opts)]
|
||||||
(the-var opts))"
|
(the-var opts))"
|
||||||
(random-uuid)
|
(random-uuid)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
{:org.babashka/cli {:coerce {:foo []}}})
|
{:org.babashka/cli {:coerce {:foo []}}})
|
||||||
|
|
||||||
(defn exec-test
|
(defn exec-test
|
||||||
{:org.babashka/cli {:coerce {:bar :keyword}}}
|
{:org.babashka/cli
|
||||||
|
{:exec-args {:foo :foo}
|
||||||
|
:coerce {:bar :keyword}}}
|
||||||
[m]
|
[m]
|
||||||
(if (:meta m)
|
(if (:meta m)
|
||||||
(prn (meta m))
|
(prn (meta m))
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@
|
||||||
(is (= {:foo [1], :bar :yeah}
|
(is (= {:foo [1], :bar :yeah}
|
||||||
(edn/read-string (bb "-cp" "test-resources" "run" "foo" "--foo" "1" "--bar" "yeah")))))
|
(edn/read-string (bb "-cp" "test-resources" "run" "foo" "--foo" "1" "--bar" "yeah")))))
|
||||||
(testing "task exec args"
|
(testing "task exec args"
|
||||||
|
(u/with-config
|
||||||
|
"{:deps {}
|
||||||
|
:tasks {foo {:task (exec 'babashka.exec-test/exec-test)}}}"
|
||||||
|
(is (= {:foo :foo, :bar :yeah}
|
||||||
|
(edn/read-string (bb "-cp" "test-resources" "run" "foo" "--bar" "yeah")))))
|
||||||
(u/with-config
|
(u/with-config
|
||||||
"{:deps {}
|
"{:deps {}
|
||||||
:tasks {foo {:exec-args {:foo :bar}
|
:tasks {foo {:exec-args {:foo :bar}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue