Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add mise support #633

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/Runner/Commands/Edit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Runner/Commands/Runner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 11 additions & 9 deletions Sources/RunnerLib/Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down