Skip to content

Commit 243beea

Browse files
authored
Merge pull request #144 from compnerd/resolution
TSCBasic: correct `resolveSymlink` on Windows
2 parents 8a31bf0 + 49ed191 commit 243beea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: Sources/TSCBasic/PathShims.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import Foundation
2323
/// Returns the "real path" corresponding to `path` by resolving any symbolic links.
2424
public func resolveSymlinks(_ path: AbsolutePath) -> AbsolutePath {
2525
#if os(Windows)
26-
let resolved: String =
27-
(try? FileManager.default.destinationOfSymbolicLink(atPath: path.pathString))
28-
?? path.pathString
26+
var resolved: URL = URL(fileURLWithPath: path.pathString)
27+
if let destination = try? FileManager.default.destinationOfSymbolicLink(atPath: path.pathString) {
28+
resolved = URL(fileURLWithPath: destination, relativeTo: URL(fileURLWithPath: path.pathString))
29+
}
2930

30-
return URL(fileURLWithPath: resolved.standardizingPath)
31-
.withUnsafeFileSystemRepresentation {
31+
return resolved.standardized.withUnsafeFileSystemRepresentation {
3232
try! AbsolutePath(validating: String(cString: $0!))
3333
}
3434
#else

0 commit comments

Comments
 (0)