mirror of
https://github.com/go-task/task.git
synced 2026-06-23 20:55:52 +00:00
Added included taskfile directory resolving
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user