mirror of
https://github.com/go-task/task.git
synced 2025-01-20 04:59:37 +02:00
parent
4ed4ad9852
commit
a9b1f38a7c
@ -20,12 +20,24 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error {
|
||||
if t2.Output != "" {
|
||||
t1.Output = t2.Output
|
||||
}
|
||||
|
||||
if t1.Includes == nil {
|
||||
t1.Includes = make(map[string]string)
|
||||
}
|
||||
for k, v := range t2.Includes {
|
||||
t1.Includes[k] = v
|
||||
}
|
||||
|
||||
if t1.Vars == nil {
|
||||
t1.Vars = make(Vars)
|
||||
}
|
||||
for k, v := range t2.Vars {
|
||||
t1.Vars[k] = v
|
||||
}
|
||||
|
||||
if t1.Tasks == nil {
|
||||
t1.Tasks = make(Tasks)
|
||||
}
|
||||
for k, v := range t2.Tasks {
|
||||
t1.Tasks[taskNameWithNamespace(k, namespaces...)] = v
|
||||
}
|
||||
|
12
task_test.go
12
task_test.go
@ -484,3 +484,15 @@ func TestIncludes(t *testing.T) {
|
||||
}
|
||||
tt.Run(t)
|
||||
}
|
||||
|
||||
func TestIncludesEmptyMain(t *testing.T) {
|
||||
tt := fileContentTest{
|
||||
Dir: "testdata/includes_empty",
|
||||
Target: "included:default",
|
||||
TrimSpace: true,
|
||||
Files: map[string]string{
|
||||
"file.txt": "default",
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
}
|
||||
|
1
testdata/includes_empty/.gitignore
vendored
Normal file
1
testdata/includes_empty/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
file.txt
|
4
testdata/includes_empty/Taskfile.yml
vendored
Normal file
4
testdata/includes_empty/Taskfile.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
version: '2'
|
||||
|
||||
includes:
|
||||
included: Taskfile2.yml
|
10
testdata/includes_empty/Taskfile2.yml
vendored
Normal file
10
testdata/includes_empty/Taskfile2.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
version: '2'
|
||||
|
||||
vars:
|
||||
FILE: file.txt
|
||||
CONTENT: default
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- echo "{{.CONTENT}}" > {{.FILE}}
|
Loading…
x
Reference in New Issue
Block a user