mirror of
https://github.com/go-task/task.git
synced 2025-05-31 23:19:42 +02:00
Added os-related files for included taskfiles
This commit is contained in:
parent
7a8142ed92
commit
8ff81562d2
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/go-task/task/v2/internal/taskfile"
|
||||
|
||||
@ -45,6 +46,19 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
|
||||
return nil, ErrIncludedTaskfilesCantHaveIncludes
|
||||
}
|
||||
|
||||
includedTaskDirectory := filepath.Dir(path)
|
||||
includedTaskFileName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
|
||||
path = filepath.Join(includedTaskDirectory, fmt.Sprintf("%s_%s.yml", includedTaskFileName, runtime.GOOS))
|
||||
if _, err = os.Stat(path); err == nil {
|
||||
osIncludedTaskfile, err := readTaskfile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = taskfile.Merge(includedTaskfile, osIncludedTaskfile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, task := range includedTaskfile.Tasks {
|
||||
task.Dir = filepath.Join(includedTask.Dir, task.Dir)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user