fsext

package
v3.46.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir(entrypoint, dir string) string

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

func ResolveDir(entrypoint, resolvedEntrypoint, dir string) (string, error)

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(entrypoint, dir string, possibleFilenames []string) (string, error)

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

func SearchAll(entrypoint, dir string, possibleFilenames []string) ([]string, error)

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

func SearchNPathRecursively(path string, possibleFilenames []string, n int) ([]string, error)

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

func SearchPath(path string, possibleFilenames []string) (string, error)

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

func SearchPathRecursively(path string, possibleFilenames []string) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL