diff options
| author | 2023-04-28 01:36:55 +0800 | |
|---|---|---|
| committer | 2023-04-28 01:36:55 +0800 | |
| commit | fc8c5fdce62fb229202659408798a7b6c98f6e8b (patch) | |
| tree | 7554f80e50de4af6fd255afa7c21bcdd58a7af34 /cli/internal/turbopath/find_up.go | |
| parent | dd84b9d64fb98746a230cd24233ff50a562c39c9 (diff) | |
| download | HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip | |
Diffstat (limited to 'cli/internal/turbopath/find_up.go')
| -rw-r--r-- | cli/internal/turbopath/find_up.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/cli/internal/turbopath/find_up.go b/cli/internal/turbopath/find_up.go deleted file mode 100644 index bf7c39c..0000000 --- a/cli/internal/turbopath/find_up.go +++ /dev/null @@ -1,50 +0,0 @@ -package turbopath - -import ( - "os" - "path/filepath" -) - -func hasFile(name, dir string) (bool, error) { - files, err := os.ReadDir(dir) - - if err != nil { - return false, err - } - - for _, f := range files { - if name == f.Name() { - return true, nil - } - } - - return false, nil -} - -func findupFrom(name, dir string) (string, error) { - for { - found, err := hasFile(name, dir) - - if err != nil { - return "", err - } - - if found { - return filepath.Join(dir, name), nil - } - - parent := filepath.Dir(dir) - - if parent == dir { - return "", nil - } - - dir = parent - } -} - -// FindupFrom Recursively finds a file by walking up parents in the file tree -// starting from a specific directory. -func FindupFrom(name, dir string) (string, error) { - return findupFrom(name, dir) -} |
