Skip to content

Commit 90bcbe9

Browse files
authored
fix: address "taskfile not found" in some environments like docker (#2709)
1 parent 60a808c commit 90bcbe9

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

internal/fsext/fs.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ func SearchPath(path string, possibleFilenames []string) (string, error) {
153153
// also check if the user ID of the directory changes and abort if it does.
154154
func SearchPathRecursively(path string, possibleFilenames []string) (string, error) {
155155
paths, err := SearchNPathRecursively(path, possibleFilenames, 1)
156-
if err != nil {
157-
return "", err
158-
}
159-
if len(paths) == 0 {
160-
return "", os.ErrNotExist
156+
if len(paths) > 0 {
157+
// Regardless of the error, return the first possible filename.
158+
return paths[0], nil
159+
} else {
160+
if err != nil {
161+
return "", err
162+
} else {
163+
return "", os.ErrNotExist
164+
}
161165
}
162-
return paths[0], nil
163166
}
164167

165168
// SearchNPathRecursively walks up the directory tree starting at the given
@@ -191,10 +194,10 @@ func SearchNPathRecursively(path string, possibleFilenames []string, n int) ([]s
191194
// If the user id of the directory changes indicate a permission error, otherwise
192195
// the calling code will infer an error condition based on the accumulated
193196
// contents of paths.
194-
if parentOwner != owner {
195-
return paths, os.ErrPermission
196-
} else if path == parentPath {
197+
if path == parentPath {
197198
return paths, nil
199+
} else if parentOwner != owner {
200+
return paths, os.ErrPermission
198201
}
199202

200203
owner = parentOwner

0 commit comments

Comments
 (0)