Skip to content

Commit 84c1916

Browse files
Fixed mainDirectory path for the urlwatcher script
1 parent 805d999 commit 84c1916

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Shared/Sources/Shared/JFLiterals.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@
88
import Foundation
99

1010
public let mainDirectory: String = {
11-
// TODO: Check what that path is depending on the executable
1211
// Save the directory, the program is executed in for the shell scripts later
13-
let mainDirectory = Bundle.main.executablePath?
12+
var components = Bundle.main.executablePath?
1413
// Remove the filename, only use the directory
15-
.split(separator: "/", omittingEmptySubsequences: false).dropLast().map(String.init).joined(separator: "/")
14+
// We don't want to remove a preceding `/`
15+
.split(separator: "/", omittingEmptySubsequences: false)
16+
.map(String.init)
17+
while components?.last?.isEmpty ?? false {
18+
components?.removeLast()
19+
}
20+
// Remove the filename
21+
components?.removeLast()
22+
// Remove the urlwatcher directory (in case we are in it right now)
23+
if components?.last == "urlwatcher" {
24+
components?.removeLast()
25+
}
26+
let mainDirectory = components?
27+
.joined(separator: "/")
1628
print("Installation Directory: \(mainDirectory ?? "nil")")
1729

1830
// If no install directory could be constructed:
@@ -56,4 +68,3 @@ public let kDiffFile = "diff.png"
5668
public let kNccThreshold = 0.999
5769
/// The duration for which a screenshot capture error has to persist for the user to be notified. Set to 0 to immediately notify on errors
5870
public let kErrorReportMinutes = 120
59-

0 commit comments

Comments
 (0)