Skip to content

Commit

Permalink
refactor: rename node resolver methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pd93 committed Mar 10, 2024
1 parent 4d4040b commit 8a34d4c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions taskfile/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type Node interface {
Dir() string
Optional() bool
Remote() bool
ResolveIncludeEntrypoint(entrypoint string) (string, error)
ResolveIncludeDir(dir string) (string, error)
ResolveEntrypoint(entrypoint string) (string, error)
ResolveDir(dir string) (string, error)
}

func NewRootNode(
Expand Down
4 changes: 2 additions & 2 deletions taskfile/node_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resolveFileNodeEntrypointAndDir(l *logger.Logger, entrypoint, dir string) (
return entrypoint, dir, nil
}

func (node *FileNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
func (node *FileNode) ResolveEntrypoint(entrypoint string) (string, error) {
// If the file is remote, we don't need to resolve the path
if strings.Contains(entrypoint, "://") {
return entrypoint, nil
Expand All @@ -98,7 +98,7 @@ func (node *FileNode) ResolveIncludeEntrypoint(entrypoint string) (string, error
return filepathext.SmartJoin(entrypointDir, path), nil
}

func (node *FileNode) ResolveIncludeDir(dir string) (string, error) {
func (node *FileNode) ResolveDir(dir string) (string, error) {
path, err := execext.Expand(dir)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions taskfile/node_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ func (node *HTTPNode) Read(ctx context.Context) ([]byte, error) {
return b, nil
}

func (node *HTTPNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
func (node *HTTPNode) ResolveEntrypoint(entrypoint string) (string, error) {
ref, err := url.Parse(entrypoint)
if err != nil {
return "", err
}
return node.URL.ResolveReference(ref).String(), nil
}

func (node *HTTPNode) ResolveIncludeDir(dir string) (string, error) {
func (node *HTTPNode) ResolveDir(dir string) (string, error) {
path, err := execext.Expand(dir)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions taskfile/node_stdin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (node *StdinNode) Read(ctx context.Context) ([]byte, error) {
return stdin, nil
}

func (node *StdinNode) ResolveIncludeEntrypoint(entrypoint string) (string, error) {
func (node *StdinNode) ResolveEntrypoint(entrypoint string) (string, error) {
// If the file is remote, we don't need to resolve the path
if strings.Contains(entrypoint, "://") {
return entrypoint, nil
Expand All @@ -62,7 +62,7 @@ func (node *StdinNode) ResolveIncludeEntrypoint(entrypoint string) (string, erro
return filepathext.SmartJoin(node.Dir(), path), nil
}

func (node *StdinNode) ResolveIncludeDir(dir string) (string, error) {
func (node *StdinNode) ResolveDir(dir string) (string, error) {
path, err := execext.Expand(dir)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions taskfile/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func Read(
return err
}

entrypoint, err := node.ResolveIncludeEntrypoint(include.Taskfile)
entrypoint, err := node.ResolveEntrypoint(include.Taskfile)
if err != nil {
return err
}

dir, err := node.ResolveIncludeDir(include.Dir)
dir, err := node.ResolveDir(include.Dir)
if err != nil {
return err
}
Expand Down

0 comments on commit 8a34d4c

Please sign in to comment.