Added included taskfile directory resolving

This commit is contained in:
Evgeny Abramovich
2020-01-29 10:03:06 +03:00
parent eaba1b9cc8
commit 7a8142ed92
3 changed files with 10 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error {
}
if t1.Includes == nil {
t1.Includes = make(map[string]string)
t1.Includes = make(IncludedTaskFiles)
}
for k, v := range t2.Includes {
t1.Includes[k] = v

View File

@@ -28,8 +28,8 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
return nil, err
}
for namespace, path := range t.Includes {
path = filepath.Join(dir, path)
for namespace, includedTask := range t.Includes {
path = filepath.Join(dir, includedTask.Taskfile)
info, err := os.Stat(path)
if err != nil {
return nil, err
@@ -44,6 +44,11 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
if len(includedTaskfile.Includes) > 0 {
return nil, ErrIncludedTaskfilesCantHaveIncludes
}
for _, task := range includedTaskfile.Tasks {
task.Dir = filepath.Join(includedTask.Dir, task.Dir)
}
if err = taskfile.Merge(t, includedTaskfile, namespace); err != nil {
return nil, err
}

View File

@@ -6,7 +6,7 @@ type Taskfile struct {
Expansions int
Output string
Method string
Includes map[string]string
Includes IncludedTaskFiles
Vars Vars
Env Vars
Tasks Tasks
@@ -20,7 +20,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
Expansions int
Output string
Method string
Includes map[string]string
Includes IncludedTaskFiles
Vars Vars
Env Vars
Tasks Tasks