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.

Homebrew is told not to ask before an upgrade

Țugui Dragoșc5ccd8a22444
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index 05423eef..49cb58a1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -770,6 +770,9 @@ public enum Homebrew {
// Otherwise an upgrade runs `brew cleanup` by itself, which deletes old versions and downloads for
// good. Peel deletes those only through Clean Up, which asks first.
"HOMEBREW_NO_INSTALL_CLEANUP": "1",
+ // `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",
]
if !autoUpdate {
values["HOMEBREW_NO_AUTO_UPDATE"] = "1"
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
index 1847558d..565ccdb9 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
@@ -13,6 +13,12 @@ struct HomebrewTests {
}
}
+ @Test func anUpgradeNeverWaitsForAnAnswer() {
+ for autoUpdate in [true, false] {
+ #expect(Homebrew.environment(autoUpdate: autoUpdate)["HOMEBREW_NO_ASK"] == "1")
+ }
+ }
+
/// `brew cleanup` and the autoremove that `brew uninstall` runs delete formulae and their old versions for good,
/// so the formulae the exclusions cover are named in `HOMEBREW_NO_CLEANUP_FORMULAE`, which Homebrew's own
/// documentation says makes it refuse to clean up or autoremove them.