Documentation
¶
Index ¶
- func DefaultDir(entrypoint, dir string) string
- func ResolveDir(entrypoint, resolvedEntrypoint, dir string) (string, error)
- func Search(entrypoint, dir string, possibleFilenames []string) (string, error)
- func SearchAll(entrypoint, dir string, possibleFilenames []string) ([]string, error)
- func SearchNPathRecursively(path string, possibleFilenames []string, n int) ([]string, error)
- func SearchPath(path string, possibleFilenames []string) (string, error)
- func SearchPathRecursively(path string, possibleFilenames []string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶
DefaultDir will return the default directory given an entrypoint or directory. If the directory is set, it will ensure it is an absolute path and return it. If the entrypoint is set, but the directory is not, it will leave the directory blank. If both are empty, it will default the directory to the current working directory.
func ResolveDir ¶ added in v3.45.0
ResolveDir returns an absolute path to the directory that the task should be run in. If the entrypoint and dir are BOTH set, then the Taskfile will not sit inside the directory specified by dir and we should ensure that the dir is absolute. Otherwise, the dir will always be the parent directory of the resolved entrypoint, so we should return that parent directory.
func Search ¶
Search looks for files with the given possible filenames using the given entrypoint and directory. If the entrypoint is set, it checks if the entrypoint matches a file or if it matches a directory containing one of the possible filenames. Otherwise, it walks up the file tree starting at the given directory and performs a search in each directory for the possible filenames until it finds a match or reaches the root directory. If the entrypoint and directory are both empty, it defaults the directory to the current working directory and performs a recursive search starting there. If a match is found, the absolute path to the file is returned with its directory. If no match is found, an error is returned.
func SearchAll ¶ added in v3.45.0
SearchAll looks for files with the given possible filenames using the given entrypoint and directory. If the entrypoint is set, it checks if the entrypoint matches a file or if it matches a directory containing one of the possible filenames and add it to a list of matches. It then walks up the file tree starting at the given directory and performs a search in each directory for the possible filenames until it finds a match or reaches the root directory. If the entrypoint and directory are both empty, it defaults the directory to the current working directory and performs a recursive search starting there. If matches are found, the absolute path to each file is added to the list and returned.
func SearchNPathRecursively ¶ added in v3.45.0
SearchNPathRecursively walks up the directory tree starting at the given path, calling the Search function in each directory and adding each matching file that it finds to a list until it reaches the root directory or the length of the list exceeds n. On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.
func SearchPath ¶
SearchPath will check if a file at the given path exists or not. If it does, it will return the path to it. If it does not, it will search for any files at the given path with any of the given possible names. If any of these match a file, the first matching path will be returned. If no files are found, an error will be returned.
func SearchPathRecursively ¶
SearchPathRecursively walks up the directory tree starting at the given path, calling the Search function in each directory until it finds a matching file or reaches the root directory. On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.
Types ¶
This section is empty.