Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func run() error {
task.WithVersionCheck(true),
)
if err := e.Setup(); err != nil {
if errors.Is(err, errors.TaskfileNotFoundError{}) {
return errors.New("No supported taskfile was found: " +
"please check the documentation for a list of supported file names.")
}
return err
}

Expand Down
8 changes: 8 additions & 0 deletions errors/errors_taskfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
return CodeTaskfileNotFound
}

func (err TaskfileNotFoundError) Is(target error) bool {
_, ok := target.(TaskfileNotFoundError)
if ok {

Check failure on line 32 in errors/errors_taskfile.go

View workflow job for this annotation

GitHub Actions / Lint (1.23.x)

S1008: should use 'return ok' instead of 'if ok { return true }; return false' (staticcheck)
return true
}
return false
}

// TaskfileAlreadyExistsError is returned on creating a Taskfile if one already
// exists.
type TaskfileAlreadyExistsError struct{}
Expand Down
12 changes: 12 additions & 0 deletions taskfile/node_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package taskfile

import (
"io"
"io/fs"
"os"
"path/filepath"
"strings"

"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"
Expand All @@ -22,6 +24,16 @@ func NewFileNode(entrypoint, dir string, opts ...NodeOption) (*FileNode, error)
base := NewBaseNode(dir, opts...)
entrypoint, base.dir, err = fsext.Search(entrypoint, base.dir, defaultTaskfiles)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
// We include the path in the error if one exists
var pathErr *fs.PathError
if errors.As(err, &pathErr) {
return nil, &errors.TaskfileNotFoundError{
URI: pathErr.Path,
}
}
return nil, &errors.TaskfileNotFoundError{}
}
return nil, err
}
return &FileNode{
Expand Down
Loading