mirror of
https://github.com/go-task/task.git
synced 2025-04-13 11:50:50 +02:00
Fix issue on running dependencies or tasks on included Taskfiles
Fixes #151
This commit is contained in:
parent
a9b1f38a7c
commit
95b75c5330
@ -39,7 +39,20 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error {
|
|||||||
t1.Tasks = make(Tasks)
|
t1.Tasks = make(Tasks)
|
||||||
}
|
}
|
||||||
for k, v := range t2.Tasks {
|
for k, v := range t2.Tasks {
|
||||||
|
// FIXME(@andreynering): Refactor this block, otherwise we can
|
||||||
|
// have serious side-effects in the future, since we're editing
|
||||||
|
// the original references instead of deep copying them.
|
||||||
|
|
||||||
t1.Tasks[taskNameWithNamespace(k, namespaces...)] = v
|
t1.Tasks[taskNameWithNamespace(k, namespaces...)] = v
|
||||||
|
|
||||||
|
for _, dep := range v.Deps {
|
||||||
|
dep.Task = taskNameWithNamespace(dep.Task, namespaces...)
|
||||||
|
}
|
||||||
|
for _, cmd := range v.Cmds {
|
||||||
|
if cmd.Task != "" {
|
||||||
|
cmd.Task = taskNameWithNamespace(cmd.Task, namespaces...)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
14
task_test.go
14
task_test.go
@ -496,3 +496,17 @@ func TestIncludesEmptyMain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tt.Run(t)
|
tt.Run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIncludesDependencies(t *testing.T) {
|
||||||
|
tt := fileContentTest{
|
||||||
|
Dir: "testdata/includes_deps",
|
||||||
|
Target: "default",
|
||||||
|
TrimSpace: true,
|
||||||
|
Files: map[string]string{
|
||||||
|
"default.txt": "default",
|
||||||
|
"called_dep.txt": "called_dep",
|
||||||
|
"called_task.txt": "called_task",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
tt.Run(t)
|
||||||
|
}
|
||||||
|
1
testdata/includes_deps/.gitignore
vendored
Normal file
1
testdata/includes_deps/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.txt
|
9
testdata/includes_deps/Taskfile.yml
vendored
Normal file
9
testdata/includes_deps/Taskfile.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
included: Taskfile2.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
cmds:
|
||||||
|
- task: included:default
|
16
testdata/includes_deps/Taskfile2.yml
vendored
Normal file
16
testdata/includes_deps/Taskfile2.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
deps: [called_dep]
|
||||||
|
cmds:
|
||||||
|
- echo "default" > default.txt
|
||||||
|
- task: called_task
|
||||||
|
|
||||||
|
called_dep:
|
||||||
|
cmds:
|
||||||
|
- echo "called_dep" > called_dep.txt
|
||||||
|
|
||||||
|
called_task:
|
||||||
|
cmds:
|
||||||
|
- echo "called_task" > called_task.txt
|
Loading…
x
Reference in New Issue
Block a user