File tree Expand file tree Collapse file tree 1 file changed +9
-18
lines changed
Expand file tree Collapse file tree 1 file changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -85,33 +85,24 @@ public func lookupExecutablePath(
8585 return nil
8686 }
8787
88- let path : AbsolutePath
88+ var paths : [ AbsolutePath ] = [ ]
89+
8990 if let cwd = currentWorkingDirectory {
9091 // We have a value, but it could be an absolute or a relative path.
91- path = AbsolutePath ( value, relativeTo: cwd)
92+ paths . append ( AbsolutePath ( value, relativeTo: cwd) )
9293 } else if let absPath = try ? AbsolutePath ( validating: value) {
9394 // Current directory not being available is not a problem
9495 // for the absolute-specified paths.
95- path = absPath
96- } else {
97- return nil
96+ paths. append ( absPath)
9897 }
9998
100- if localFileSystem. isExecutableFile ( path) {
101- return path
102- }
10399 // Ensure the value is not a path.
104- guard !value. contains ( " / " ) else {
105- return nil
100+ if !value. contains ( " / " ) {
101+ // Try to locate in search paths.
102+ paths. append ( contentsOf: searchPaths. map ( { $0. appending ( component: value) } ) )
106103 }
107- // Try to locate in search paths.
108- for path in searchPaths {
109- let exec = path. appending ( component: value)
110- if localFileSystem. isExecutableFile ( exec) {
111- return exec
112- }
113- }
114- return nil
104+
105+ return paths. first ( where: { localFileSystem. isExecutableFile ( $0) } )
115106}
116107
117108/// A wrapper for Range to make it Codable.
You can’t perform that action at this time.
0 commit comments