task
task copied to clipboard
Support loops in dependencies as well
Allow specifying loops in task dependencies the same way they can be used in cmds
Taskfile:
version: '3'
tasks:
deptask:
desc: dependency task
cmds:
- echo dependency foo {{.FOO}}
default:
desc: some task
deps:
- for: ['foo', 'bar']
task: deptask
vars:
FOO: "DEP-{{.ITEM}}"
cmds:
- for: ['foo', 'bar']
task: deptask
vars:
FOO: "ROOT-{{.ITEM}}"
Expected output
task: [deptask] echo dependency foo DEP-foo
dependency foo DEP-foo
task: [deptask] echo dependency foo DEP-bar
dependency foo DEP-bar
task: [deptask] echo dependency foo ROOT-foo
dependency foo ROOT-foo
task: [deptask] echo dependency foo ROOT-bar
dependency foo ROOT-bar
Actual output
task: [deptask] echo dependency foo DEP-
dependency foo DEP-
task: [deptask] echo dependency foo ROOT-foo
dependency foo ROOT-foo
task: [deptask] echo dependency foo ROOT-bar
dependency foo ROOT-bar
- Task version: v3.28.0 (h1:PGYGwevlGQdYrqhO6lLCYylC7YuGoQLlVwHkO42gf0I=)
Perhaps this is obvious to others, but is there a reason this isn't desirable?
version: '3'
tasks:
deptask:
desc: dependency task
cmds:
- echo dependency foo {{.FOO}}
default:
desc: some task
cmds:
- for: ['foo', 'bar']
task: deptask
vars:
FOO: "DEP-{{.ITEM}}"
- for: ['foo', 'bar']
task: deptask
vars:
FOO: "ROOT-{{.ITEM}}"
If it's because deptask isn't run in parallel, I wonder about your thoughts on #1300.
sorry for not mentioning it, but the reason is parallelism, as you mentioned.
i don't like the "parallel for" syntax too much, as there's no reason to specialize it. something like this is more generic, and makes more sense to me:
version: '3'
tasks:
deptask:
desc: dependency task
cmds:
- echo dependency foo {{.FOO}}
default:
desc: some task
cmds:
- parallel:
- echo first command
- for: ['foo', 'bar']
task: deptask
vars:
FOO: "DEP-{{.ITEM}}"
- echo last command
i.e. specifying all the parallel commands in a separate group. it is also nicer since it can replace the deps altogether.
i think it is a better solution, but having loops support in "deps" (similar to "cmds") is good enough for my usecase.
Would really love to see this feature too!
+1 on the feature