Skip to content

Commit 66889f0

Browse files
committed
Automatically add .exe suffix on Windows
1 parent c98cfc2 commit 66889f0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/TSCBasic/misc.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,20 @@ public func lookupExecutablePath(
8787
) -> AbsolutePath? {
8888

8989
// We should have a value to continue.
90+
#if os(Windows)
91+
guard var value = value, !value.isEmpty else {
92+
return nil
93+
}
94+
let isPath = value.contains("\\")
95+
if !isPath && value.contains(".") {
96+
value.append(executableFileSuffix)
97+
}
98+
#else
9099
guard let value = value, !value.isEmpty else {
91100
return nil
92101
}
102+
let isPath = value.contains("/")
103+
#endif
93104

94105
var paths: [AbsolutePath] = []
95106

@@ -103,7 +114,7 @@ public func lookupExecutablePath(
103114
}
104115

105116
// Ensure the value is not a path.
106-
if !value.contains("/") {
117+
if !isPath {
107118
// Try to locate in search paths.
108119
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value) }))
109120
}

0 commit comments

Comments
 (0)