Skip to content

Commit 345ccba

Browse files
committed
Automatically add .exe suffix on Windows
1 parent 08800c5 commit 345ccba

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
@@ -94,9 +94,20 @@ public func lookupExecutablePath(
9494
) -> AbsolutePath? {
9595

9696
// We should have a value to continue.
97+
#if os(Windows)
98+
guard var value = value, !value.isEmpty else {
99+
return nil
100+
}
101+
let isPath = value.contains("\\")
102+
if !isPath && value.contains(".") {
103+
value.append(executableFileSuffix)
104+
}
105+
#else
97106
guard let value = value, !value.isEmpty else {
98107
return nil
99108
}
109+
let isPath = value.contains("/")
110+
#endif
100111

101112
var paths: [AbsolutePath] = []
102113

@@ -110,7 +121,7 @@ public func lookupExecutablePath(
110121
}
111122

112123
// Ensure the value is not a path.
113-
if !value.contains("/") {
124+
if !isPath {
114125
// Try to locate in search paths.
115126
paths.append(contentsOf: searchPaths.map({ $0.appending(component: value) }))
116127
}

0 commit comments

Comments
 (0)