Skip to content

Commit 0f9a054

Browse files
authored
tstest/tailmac: fix Host.app path generation (tailscale#13953)
updates tailscale/corp#24197 Generation of the Host.app path was erroneous and tailmac run would not work unless the pwd was tailmac/bin. Now you can be able to invoke tailmac from anywhere. Signed-off-by: Jonathan Nobels <[email protected]>
1 parent 9545e36 commit 0f9a054

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tstest/tailmac/Swift/TailMac/TailMac.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ extension Tailmac {
100100
mutating func run() {
101101
let process = Process()
102102
let stdOutPipe = Pipe()
103-
let appPath = "./Host.app/Contents/MacOS/Host"
103+
104+
let executablePath = CommandLine.arguments[0]
105+
let executableDirectory = (executablePath as NSString).deletingLastPathComponent
106+
let appPath = executableDirectory + "/Host.app/Contents/MacOS/Host"
104107

105108
process.executableURL = URL(
106109
fileURLWithPath: appPath,
@@ -109,7 +112,7 @@ extension Tailmac {
109112
)
110113

111114
if !FileManager.default.fileExists(atPath: appPath) {
112-
fatalError("Could not find Host.app. This must be co-located with the tailmac utility")
115+
fatalError("Could not find Host.app at \(appPath). This must be co-located with the tailmac utility")
113116
}
114117

115118
process.arguments = ["run", "--id", id]

0 commit comments

Comments
 (0)