MCPcopy
hub / github.com/go-task/task / NewFileNode

Function NewFileNode

taskfile/node_file.go:20–46  ·  view source on GitHub ↗
(entrypoint, dir string, opts ...NodeOption)

Source from the content-addressed store, hash-verified

18}
19
20func NewFileNode(entrypoint, dir string, opts ...NodeOption) (*FileNode, error) {
21 // Find the entrypoint file
22 resolvedEntrypoint, err := fsext.Search(entrypoint, dir, DefaultTaskfiles)
23 if err != nil {
24 if errors.Is(err, os.ErrNotExist) {
25 if entrypoint == "" {
26 return nil, errors.TaskfileNotFoundError{URI: entrypoint, Walk: true}
27 } else {
28 return nil, errors.TaskfileNotFoundError{URI: entrypoint, Walk: false}
29 }
30 } else if errors.Is(err, os.ErrPermission) {
31 return nil, errors.TaskfileNotFoundError{URI: entrypoint, Walk: true, OwnerChange: true}
32 }
33 return nil, err
34 }
35
36 // Resolve the directory
37 resolvedDir, err := fsext.ResolveDir(entrypoint, resolvedEntrypoint, dir)
38 if err != nil {
39 return nil, err
40 }
41
42 return &FileNode{
43 baseNode: NewBaseNode(resolvedDir, opts...),
44 entrypoint: resolvedEntrypoint,
45 }, nil
46}
47
48func (node *FileNode) Location() string {
49 return node.entrypoint

Callers 1

NewNodeFunction · 0.85

Calls 4

SearchFunction · 0.92
IsFunction · 0.92
ResolveDirFunction · 0.92
NewBaseNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…