mirror of
https://github.com/go-task/task.git
synced 2025-06-27 00:51:05 +02:00
fix(#612): Add nil check for included cmd
This commit is contained in:
17
task_test.go
17
task_test.go
@ -756,14 +756,14 @@ func TestIncludesCallingRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIncludesOptional(t *testing.T) {
|
func TestIncludesOptional(t *testing.T) {
|
||||||
tt := fileContentTest{
|
tt := fileContentTest{
|
||||||
Dir: "testdata/includes_optional",
|
Dir: "testdata/includes_optional",
|
||||||
Target: "default",
|
Target: "default",
|
||||||
TrimSpace: true,
|
TrimSpace: true,
|
||||||
Files: map[string]string{
|
Files: map[string]string{
|
||||||
"called_dep.txt": "called_dep",
|
"called_dep.txt": "called_dep",
|
||||||
}}
|
}}
|
||||||
tt.Run(t)
|
tt.Run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIncludesOptionalImplicitFalse(t *testing.T) {
|
func TestIncludesOptionalImplicitFalse(t *testing.T) {
|
||||||
@ -1033,6 +1033,7 @@ func TestIgnoreNilElements(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"nil cmd", "testdata/ignore_nil_elements/cmds"},
|
{"nil cmd", "testdata/ignore_nil_elements/cmds"},
|
||||||
{"nil dep", "testdata/ignore_nil_elements/deps"},
|
{"nil dep", "testdata/ignore_nil_elements/deps"},
|
||||||
|
{"nil include", "testdata/ignore_nil_elements/includes"},
|
||||||
{"nil precondition", "testdata/ignore_nil_elements/preconditions"},
|
{"nil precondition", "testdata/ignore_nil_elements/preconditions"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error {
|
|||||||
dep.Task = taskNameWithNamespace(dep.Task, namespaces...)
|
dep.Task = taskNameWithNamespace(dep.Task, namespaces...)
|
||||||
}
|
}
|
||||||
for _, cmd := range v.Cmds {
|
for _, cmd := range v.Cmds {
|
||||||
if cmd.Task != "" {
|
if cmd != nil && cmd.Task != "" {
|
||||||
cmd.Task = taskNameWithNamespace(cmd.Task, namespaces...)
|
cmd.Task = taskNameWithNamespace(cmd.Task, namespaces...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
testdata/ignore_nil_elements/includes/Taskfile.yml
vendored
Normal file
9
testdata/ignore_nil_elements/includes/Taskfile.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
inc: inc.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
cmds:
|
||||||
|
- task: inc:default
|
7
testdata/ignore_nil_elements/includes/inc.yml
vendored
Normal file
7
testdata/ignore_nil_elements/includes/inc.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
cmds:
|
||||||
|
-
|
||||||
|
- echo "string-slice-1"
|
Reference in New Issue
Block a user