Skip to content

Commit ec17749

Browse files
committed
Implicitly search for .exe on Windows
1 parent 73bdc56 commit ec17749

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Sources/TSCBasic/misc.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ public func lookupExecutablePath(
224224
guard let value = value, !value.isEmpty else {
225225
return nil
226226
}
227+
#if os(Windows)
228+
let isPath = value.contains(":") || value.contains("\\") || value.contains("/")
229+
#else
230+
let isPath = value.contains("/")
231+
#endif
227232

228233
var paths: [AbsolutePath] = []
229234

@@ -237,9 +242,14 @@ public func lookupExecutablePath(
237242
}
238243

239244
// Ensure the value is not a path.
240-
if !value.contains("/") {
245+
if !isPath {
241246
// Try to locate in search paths.
242247
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value) }))
248+
#if os(Windows)
249+
if !value.contains(".") {
250+
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value + executableFileSuffix) }))
251+
}
252+
#endif
243253
}
244254

245255
return paths.first(where: { localFileSystem.isExecutableFile($0) })

0 commit comments

Comments
 (0)