1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

fix: better error when a Taskfile does not exist in include (#2494)

This commit is contained in:
Valentin Maerten
2025-11-11 20:37:24 +01:00
committed by GitHub
parent 19f72b7eb0
commit 17757c0c15
2 changed files with 6 additions and 2 deletions

View File

@@ -1052,7 +1052,7 @@ func TestIncludesOptionalImplicitFalse(t *testing.T) {
const dir = "testdata/includes_optional_implicit_false"
wd, _ := os.Getwd()
message := "stat %s/%s/TaskfileOptional.yml: no such file or directory"
message := "task: No Taskfile found at \"%s/%s/TaskfileOptional.yml\""
expected := fmt.Sprintf(message, wd, dir)
e := task.NewExecutor(
@@ -1072,7 +1072,7 @@ func TestIncludesOptionalExplicitFalse(t *testing.T) {
const dir = "testdata/includes_optional_explicit_false"
wd, _ := os.Getwd()
message := "stat %s/%s/TaskfileOptional.yml: no such file or directory"
message := "task: No Taskfile found at \"%s/%s/TaskfileOptional.yml\""
expected := fmt.Sprintf(message, wd, dir)
e := task.NewExecutor(

View File

@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"github.com/go-task/task/v3/errors"
"github.com/go-task/task/v3/internal/execext"
"github.com/go-task/task/v3/internal/filepathext"
"github.com/go-task/task/v3/internal/fsext"
@@ -20,6 +21,9 @@ func NewFileNode(entrypoint, dir string, opts ...NodeOption) (*FileNode, error)
// Find the entrypoint file
resolvedEntrypoint, err := fsext.Search(entrypoint, dir, defaultTaskfiles)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, errors.TaskfileNotFoundError{URI: entrypoint, Walk: false}
}
return nil, err
}