diff --git a/Sources/Runner/Commands/Edit.swift b/Sources/Runner/Commands/Edit.swift index 04c051e3..7826df3f 100644 --- a/Sources/Runner/Commands/Edit.swift +++ b/Sources/Runner/Commands/Edit.swift @@ -25,10 +25,10 @@ func editDanger(version dangerSwiftVersion: String, logger: Logger) throws { absoluteLibPath = spmDanger.buildFolder libsImport = spmDanger.xcodeImportFlags } else { - guard let libPath = Runtime.getLibDangerPath() else { - let potentialFolders = Runtime.potentialLibraryFolders + guard let libPath = Runtime.getLibDangerPath(forDangerSwiftVersion: dangerSwiftVersion) else { + let potentialFolders = Runtime.potentialLibraryFolders(forDangerSwiftVersion: dangerSwiftVersion) logger.logError("Could not find a libDanger to link against at any of: \(potentialFolders)", - "Or via Homebrew, or Marathon", + "Or via Homebrew, or Marathon, or Mise", separator: "\n") exit(1) } diff --git a/Sources/Runner/Commands/Runner.swift b/Sources/Runner/Commands/Runner.swift index cd14ef65..cc40f90e 100644 --- a/Sources/Runner/Commands/Runner.swift +++ b/Sources/Runner/Commands/Runner.swift @@ -63,8 +63,8 @@ func runDanger(version dangerSwiftVersion: String, logger: Logger) throws { libArgs += ["-I", spmDanger.moduleFolder] libArgs += [spmDanger.swiftcLibImport] } else { - guard let libDangerPath = Runtime.getLibDangerPath() else { - let potentialFolders = Runtime.potentialLibraryFolders + guard let libDangerPath = Runtime.getLibDangerPath(forDangerSwiftVersion: dangerSwiftVersion) else { + let potentialFolders = Runtime.potentialLibraryFolders(forDangerSwiftVersion: dangerSwiftVersion) logger.logError("Could not find a libDanger to link against at any of: \(potentialFolders)", "Or via Homebrew, or Marathon", separator: "\n") diff --git a/Sources/RunnerLib/Runtime.swift b/Sources/RunnerLib/Runtime.swift index 5840994c..9cb340dc 100644 --- a/Sources/RunnerLib/Runtime.swift +++ b/Sources/RunnerLib/Runtime.swift @@ -16,17 +16,19 @@ public enum Runtime { } /// Is this a dev build: e.g. running inside a cloned danger/danger-swift - public static let potentialLibraryFolders = [ - ".build/debug", // Working in Xcode / CLI - ".build/x86_64-unknown-linux/debug", // Danger Swift's CI - ".build/release", // Testing prod - "/usr/local/lib/danger", // Intel Homebrew installs lib stuff to here - "/opt/homebrew/lib/danger", // Apple Silicon Homebrew installs lib stuff to here - ] + public static func potentialLibraryFolders(forDangerSwiftVersion version: String) -> [String] { [ + ".build/debug", // Working in Xcode / CLI + ".build/x86_64-unknown-linux/debug", // Danger Swift's CI + ".build/release", // Testing prod + "/usr/local/lib/danger", // Intel Homebrew installs lib stuff to here + "/opt/homebrew/lib/danger", // Apple Silicon Homebrew installs lib stuff to here + NSHomeDirectory() + "/.local/share/mise/installs/danger-swift/\(version)/lib/danger" + ] + } /// Finds a path to add at runtime to the compiler, which links /// to the library Danger - public static func getLibDangerPath() -> String? { + public static func getLibDangerPath(forDangerSwiftVersion version: String) -> String? { let fileManager = FileManager.default // Was danger-swift installed via marathon? @@ -49,7 +51,7 @@ public enum Runtime { } ?? [] // Check and find where we can link to libDanger from - let libPaths = commandArgPath + potentialLibraryFolders + depManagerDangerLibPaths + let libPaths = commandArgPath + potentialLibraryFolders(forDangerSwiftVersion: version) + depManagerDangerLibPaths func isTheDangerLibPath(path: String) -> Bool { fileManager.fileExists(atPath: path + "/libDanger.dylib") || // OSX