Start support to including Taskfiles

This commit is contained in:
Andrey Nering
2018-09-09 22:29:29 -03:00
parent 687b4ec837
commit 9a5a1e2253
3 changed files with 33 additions and 2 deletions

View File

@@ -19,6 +19,23 @@ func Taskfile(dir string) (*taskfile.Taskfile, error) {
return nil, fmt.Errorf(`No Taskfile.yml found. Use "task --init" to create a new one`)
}
for namespace, path := range t.Includes {
info, err := os.Stat(path)
if err != nil {
return nil, err
}
if info.IsDir() {
path = filepath.Join(path, "Taskfile.yml")
}
includedTaskfile, err := readTaskfile(path)
if err != nil {
return nil, err
}
if err = taskfile.Merge(t, includedTaskfile, namespace); err != nil {
return nil, err
}
}
path = filepath.Join(dir, fmt.Sprintf("Taskfile_%s.yml", runtime.GOOS))
if _, err = os.Stat(path); err == nil {
osTaskfile, err := readTaskfile(path)