1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Fix bug in includes where default taskfiles were not being checked.

This commit is contained in:
tylermmorton
2022-02-21 15:31:55 -05:00
parent 7cdf0000d9
commit 1f1275255c
9 changed files with 28 additions and 9 deletions

View File

@@ -758,7 +758,11 @@ func TestIncludesMultiLevel(t *testing.T) {
Dir: "testdata/includes_multi_level",
Target: "default",
TrimSpace: true,
Files: map[string]string{},
Files: map[string]string{
"called_one.txt": "one",
"called_two.txt": "two",
"called_three.txt": "three",
},
}
tt.Run(t)
}

View File

@@ -76,6 +76,13 @@ func Taskfile(readerNode *ReaderNode) (*taskfile.Taskfile, error) {
if !filepath.IsAbs(path) {
path = filepath.Join(readerNode.Dir, path)
}
path, err = exists(path)
if err != nil {
if includedTask.Optional {
return nil
}
return err
}
includeReaderNode := &ReaderNode{
Dir: filepath.Dir(path),

View File

@@ -1,9 +1,11 @@
version: '3'
includes:
'one': ./one/Taskfile.yml
'one': ./one/
tasks:
default:
cmds:
- task: one:default
- task: one:two:default
- task: one:two:three:default

View File

@@ -0,0 +1 @@
one

View File

@@ -0,0 +1 @@
three

View File

@@ -0,0 +1 @@
two

View File

@@ -1,9 +1,7 @@
version: '3'
includes:
'two': ./two/Taskfile.yml
'two': ./two/
tasks:
level1:
cmds:
- echo "hello level 1"
default: echo one > called_one.txt

View File

@@ -1,6 +1,7 @@
version: '3'
includes:
'three': ./three/Taskfile.yml
tasks:
default:
cmds:
- echo "called_dep" > called_dep.txt
default: echo two > called_two.txt

View File

@@ -0,0 +1,4 @@
version: '3'
tasks:
default: echo three > called_three.txt