1
0
mirror of https://github.com/go-task/task.git synced 2025-04-13 11:50:50 +02:00

fix: missing task locations

This commit is contained in:
Pete Davison 2023-09-15 12:06:23 +00:00
parent 6ecfb634d2
commit b10c573270

View File

@ -255,7 +255,19 @@ func (r *Reader) readNode(node Node) (*ast.Taskfile, error) {
if err := yaml.Unmarshal(b, &t); err != nil {
return nil, &errors.TaskfileInvalidError{URI: filepathext.TryAbsToRel(node.Location()), Err: err}
}
// Set the taskfile/task's locations
t.Location = node.Location()
for _, task := range t.Tasks.Values() {
// If the task is not defined, create a new one
if task == nil {
task = &ast.Task{}
}
// Set the location of the taskfile for each task
if task.Location.Taskfile == "" {
task.Location.Taskfile = t.Location
}
}
return &t, nil
}