Merge branch 'serial-brew': brew commands run one at a time

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
maxsoch 2026-07-07 06:10:54 +02:00
commit ec33fbcf6c

View file

@ -198,10 +198,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return url
}
/// Serial: brew commands run strictly one after another. Concurrent brew
/// processes could each summon their own sudo password dialog (and their
/// log output interleaved); queueing them prevents both.
static let brewQueue = DispatchQueue(label: "fr.socheleau.BrewBar.brew")
/// askpassMessage customizes the sudo dialog ("...password to <message>.");
/// defaults to naming the brew command.
func runBrew(_ command: String, askpassMessage: String? = nil, completion: @escaping (String) -> Void = { _ in }) {
DispatchQueue.global().async {
Self.brewQueue.async {
let brew = self.resolveBrewPath()
let cleaned = command.replacingOccurrences(of: "brew ", with: "")
let arguments = [brew] + cleaned.split(separator: " ").map(String.init)