Skip to content

Commit 90ec47d

Browse files
committed
Implicitly search for .exe on Windows
1 parent 869dafb commit 90ec47d

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
@@ -97,6 +97,11 @@ public func lookupExecutablePath(
9797
guard let value = value, !value.isEmpty else {
9898
return nil
9999
}
100+
#if os(Windows)
101+
let isPath = value.contains(":") || value.contains("\\") || value.contains("/")
102+
#else
103+
let isPath = value.contains("/")
104+
#endif
100105

101106
var paths: [AbsolutePath] = []
102107

@@ -110,9 +115,14 @@ public func lookupExecutablePath(
110115
}
111116

112117
// Ensure the value is not a path.
113-
if !value.contains("/") {
118+
if !isPath {
114119
// Try to locate in search paths.
115120
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value) }))
121+
#if os(Windows)
122+
if !value.contains(".") {
123+
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value + executableFileSuffix) }))
124+
}
125+
#endif
116126
}
117127

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

0 commit comments

Comments
 (0)