mirror of
https://github.com/go-task/task.git
synced 2025-04-25 12:25:07 +02:00
feat: don't send entire include to node resolvers
This commit is contained in:
parent
cbc19d35ea
commit
68191205c7
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/go-task/task/v3/errors"
|
"github.com/go-task/task/v3/errors"
|
||||||
"github.com/go-task/task/v3/internal/experiments"
|
"github.com/go-task/task/v3/internal/experiments"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/taskfile/ast"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Node interface {
|
type Node interface {
|
||||||
@ -19,8 +18,8 @@ type Node interface {
|
|||||||
Dir() string
|
Dir() string
|
||||||
Optional() bool
|
Optional() bool
|
||||||
Remote() bool
|
Remote() bool
|
||||||
ResolveIncludeEntrypoint(include ast.Include) (string, error)
|
ResolveIncludeEntrypoint(entrypoint string) (string, error)
|
||||||
ResolveIncludeDir(include ast.Include) (string, error)
|
ResolveIncludeDir(dir string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRootNode(
|
func NewRootNode(
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/filepathext"
|
"github.com/go-task/task/v3/internal/filepathext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/taskfile/ast"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A FileNode is a node that reads a taskfile from the local filesystem.
|
// A FileNode is a node that reads a taskfile from the local filesystem.
|
||||||
@ -78,13 +77,13 @@ func resolveFileNodeEntrypointAndDir(l *logger.Logger, entrypoint, dir string) (
|
|||||||
return entrypoint, dir, nil
|
return entrypoint, dir, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *FileNode) ResolveIncludeEntrypoint(include ast.Include) (string, error) {
|
func (node *FileNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
|
||||||
// If the file is remote, we don't need to resolve the path
|
// If the file is remote, we don't need to resolve the path
|
||||||
if strings.Contains(include.Taskfile, "://") {
|
if strings.Contains(entrypoint, "://") {
|
||||||
return include.Taskfile, nil
|
return entrypoint, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
path, err := execext.Expand(include.Taskfile)
|
path, err := execext.Expand(entrypoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -99,8 +98,8 @@ func (node *FileNode) ResolveIncludeEntrypoint(include ast.Include) (string, err
|
|||||||
return filepathext.SmartJoin(entrypointDir, path), nil
|
return filepathext.SmartJoin(entrypointDir, path), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *FileNode) ResolveIncludeDir(include ast.Include) (string, error) {
|
func (node *FileNode) ResolveIncludeDir(dir string) (string, error) {
|
||||||
path, err := execext.Expand(include.Dir)
|
path, err := execext.Expand(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/filepathext"
|
"github.com/go-task/task/v3/internal/filepathext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/taskfile/ast"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// An HTTPNode is a node that reads a Taskfile from a remote location via HTTP.
|
// An HTTPNode is a node that reads a Taskfile from a remote location via HTTP.
|
||||||
@ -76,16 +75,16 @@ func (node *HTTPNode) Read(ctx context.Context) ([]byte, error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *HTTPNode) ResolveIncludeEntrypoint(include ast.Include) (string, error) {
|
func (node *HTTPNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
|
||||||
ref, err := url.Parse(include.Taskfile)
|
ref, err := url.Parse(entrypoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return node.URL.ResolveReference(ref).String(), nil
|
return node.URL.ResolveReference(ref).String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *HTTPNode) ResolveIncludeDir(include ast.Include) (string, error) {
|
func (node *HTTPNode) ResolveIncludeDir(dir string) (string, error) {
|
||||||
path, err := execext.Expand(include.Dir)
|
path, err := execext.Expand(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/filepathext"
|
"github.com/go-task/task/v3/internal/filepathext"
|
||||||
"github.com/go-task/task/v3/taskfile/ast"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A StdinNode is a node that reads a taskfile from the standard input stream.
|
// A StdinNode is a node that reads a taskfile from the standard input stream.
|
||||||
@ -45,13 +44,13 @@ func (node *StdinNode) Read(ctx context.Context) ([]byte, error) {
|
|||||||
return stdin, nil
|
return stdin, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *StdinNode) ResolveIncludeEntrypoint(include ast.Include) (string, error) {
|
func (node *StdinNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
|
||||||
// If the file is remote, we don't need to resolve the path
|
// If the file is remote, we don't need to resolve the path
|
||||||
if strings.Contains(include.Taskfile, "://") {
|
if strings.Contains(entrypoint, "://") {
|
||||||
return include.Taskfile, nil
|
return entrypoint, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
path, err := execext.Expand(include.Taskfile)
|
path, err := execext.Expand(entrypoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -63,8 +62,8 @@ func (node *StdinNode) ResolveIncludeEntrypoint(include ast.Include) (string, er
|
|||||||
return filepathext.SmartJoin(node.Dir(), path), nil
|
return filepathext.SmartJoin(node.Dir(), path), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *StdinNode) ResolveIncludeDir(include ast.Include) (string, error) {
|
func (node *StdinNode) ResolveIncludeDir(dir string) (string, error) {
|
||||||
path, err := execext.Expand(include.Dir)
|
path, err := execext.Expand(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,12 @@ func Read(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
entrypoint, err := node.ResolveIncludeEntrypoint(include)
|
entrypoint, err := node.ResolveIncludeEntrypoint(include.Taskfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := node.ResolveIncludeDir(include)
|
dir, err := node.ResolveIncludeDir(include.Dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user