|
8 | 8 | import Foundation |
9 | 9 |
|
10 | 10 | public let mainDirectory: String = { |
11 | | - // TODO: Check what that path is depending on the executable |
12 | 11 | // 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? |
14 | 13 | // 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: "/") |
16 | 28 | print("Installation Directory: \(mainDirectory ?? "nil")") |
17 | 29 |
|
18 | 30 | // If no install directory could be constructed: |
@@ -56,4 +68,3 @@ public let kDiffFile = "diff.png" |
56 | 68 | public let kNccThreshold = 0.999 |
57 | 69 | /// 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 |
58 | 70 | public let kErrorReportMinutes = 120 |
59 | | - |
|
0 commit comments