(entrypoint, dir string, opts ...NodeOption)
| 18 | } |
| 19 | |
| 20 | func 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 | |
| 48 | func (node *FileNode) Location() string { |
| 49 | return node.entrypoint |
no test coverage detected
searching dependent graphs…