Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Count Homebrew's peel link in Settings, as Home does

Țugui Dragoșbc5e071157f3
diff --git a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift b/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
index 53f132e7..e80de356 100644
--- a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Home/Access.swift
@@ -59,6 +59,12 @@ public enum CommandLineTool {
paths.contains { standing(at: $0, embedded: embedded) == .installed }
}
+ /// The link's standing as Settings and Home show it: installed once any of `paths` leads to this copy's tool, as
+ /// Homebrew's does on a Mac with Apple silicon, and otherwise the standing of the link Peel offers to make.
+ public static func standingOnThePath(embedded: URL, at paths: [String] = paths) -> Standing {
+ isOnThePath(embedded: embedded, at: paths) ? .installed : standing(at: paths[0], embedded: embedded)
+ }
+
public enum Standing: Sendable, Hashable {
case installed
case missing
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
index 3f0fdfb8..dff11a6b 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift
@@ -281,6 +281,9 @@ struct AppManagementTests {
)
#expect(isOnThePath(), "Homebrew's link was not counted")
#expect(CommandLineTool.paths == ["/usr/local/bin/peel", "/opt/homebrew/bin/peel"])
+ let standing = CommandLineTool.standingOnThePath(embedded: embedded, at: [peels, homebrews])
+ #expect(standing == .installed)
+ #expect(CommandLineTool.installCommand(embedded: embedded, standing: standing) == nil)
}
/// The install command points to where Peel is, so it is only worth offering where Peel stays. The copy macOS
diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swift
index ea2cbdd8..e3ce148b 100644
--- a/Peel/Model/HomeModel.swift
+++ b/Peel/Model/HomeModel.swift
@@ -310,7 +310,7 @@ final class HomeModel {
}
static var commandLineStanding: CommandLineTool.Standing {
- CommandLineTool.standing(embedded: Bundle.main.bundleURL.appending(path: "Contents/Helpers/peel"))
+ CommandLineTool.standingOnThePath(embedded: Bundle.main.bundleURL.appending(path: "Contents/Helpers/peel"))
}
}