Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Run Homebrew's health check without CI, which skips a check
Țugui Dragoș20dbff656034
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swiftindex 7cf77d34..c4ba683a 100644--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift@@ -876,7 +876,9 @@ public enum Homebrew {/// it; an older one is asked for `healthReport()` instead.@concurrentpublic static func health() async throws(CommandFailure) -> [HomebrewFinding] {- let attempt = try await execute(["doctor", "--json"], autoUpdate: false, timeout: longestCommand)+ let attempt = try await execute(+ ["doctor", "--json"], autoUpdate: false, timeout: longestCommand, writesLinesAsTheyGo: false+ )guard let report = try? JSONDecoder().decode(DoctorReport.self, from: Data(attempt.standardOutput.utf8)) else {throw CommandFailure(output: attempt.output)}@@ -898,7 +900,9 @@ public enum Homebrew {/// Returns what `brew doctor` prints, for a Homebrew that cannot be asked for JSON.@concurrentpublic static func healthReport() async -> String {- let attempt = try? await execute(["doctor"], autoUpdate: false, timeout: longestCommand, inWritingOrder: true)+ let attempt = try? await execute(+ ["doctor"], autoUpdate: false, timeout: longestCommand, inWritingOrder: true, writesLinesAsTheyGo: false+ )return attempt?.output ?? ""}@@ -1084,14 +1088,16 @@ public enum Homebrew {onOutput: (@Sendable (Data) -> Void)? = nil,executable: URL? = executableURL,readsTheAPI: Bool = true,- home: URL = .homeDirectory+ home: URL = .homeDirectory,+ writesLinesAsTheyGo: Bool = true) async throws(CommandFailure) -> Attempt {guard let executable else {throw CommandFailure(output: Self.notInstalled)}let path = executable.path(percentEncoded: false)let environment = environment(- autoUpdate: autoUpdate, keeping: kept, executable: executable, readsTheAPI: readsTheAPI, home: home+ autoUpdate: autoUpdate, keeping: kept, executable: executable, readsTheAPI: readsTheAPI, home: home,+ writesLinesAsTheyGo: writesLinesAsTheyGo)switch await Subprocess.run(path, arguments, environment: environment, timeout: timeout, errorsIntoOutput: inWritingOrder,@@ -1152,7 +1158,7 @@ public enum Homebrew {/// `brew.env` files are read after it and can still undo a setting here, which `overrides()` reports.static func environment(autoUpdate: Bool, keeping kept: [String] = [], executable: URL? = nil, readsTheAPI: Bool = true,- home: URL = .homeDirectory+ home: URL = .homeDirectory, writesLinesAsTheyGo: Bool = true) -> [String: String] {var path = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"// A Homebrew in a prefix of its own finds its own programs first, as the default ones do.@@ -1176,10 +1182,13 @@ public enum Homebrew {// `brew upgrade` asks before it goes on unless this is set, and nobody is there to answer. It skips// the question only because no terminal is attached (`ask.rb`). A version without it ignores it."HOMEBREW_NO_ASK": "1",- // `brew.rb` writes each line as it goes only under `CI`. Otherwise Ruby holds what goes to standard- // output back in a pipe, and an error printed after a step shows before it.- "CI": "1",]+ // `brew.rb` writes each line as it goes only under `CI`. Otherwise Ruby holds what goes to standard output back+ // in a pipe, and an error printed after a step shows before it. `brew doctor` reads `CI` as a CI run, though,+ // and leaves out its check of the taps' branches, so it is asked without it.+ if writesLinesAsTheyGo {+ values["CI"] = "1"+ }if !autoUpdate {values["HOMEBREW_NO_AUTO_UPDATE"] = "1"}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swiftindex 9a5501e0..699bf4d3 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift@@ -22,6 +22,12 @@ struct HomebrewTests {#expect(Homebrew.installation(versionAnswer: "Homebrew 7.0.9\n", prefixAnswer: "/p\n", cellarAnswer: "c\n") == nil)}+ @Test func asksForEachLineAsItGoesExceptOfTheHealthCheck() {+ #expect(Homebrew.environment(autoUpdate: false)["CI"] == "1")+ // `brew doctor` reads `CI` as a CI run and skips its check of the taps' branches (`diagnostic.rb`).+ #expect(Homebrew.environment(autoUpdate: false, writesLinesAsTheyGo: false)["CI"] == nil)+ }+@Test(.permissionsHold) func knowsWhetherThisAccountMayChangeHomebrew() throws {let directory = try TemporaryDirectory()let repository = try directory.directory("homebrew")