From 0a38dc5e710b8959a22343b9fdb98520617b9026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1rady=20Mil=C3=A1n?= <61704770+MilanVarady@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:19:15 +0100 Subject: [PATCH] Set brew path option after installation --- .../Brew Installation/DependencyManager.swift | 11 ++++++++++- Applite/Views/Setup/SetupView.swift | 6 +----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Applite/Utilities/Brew Installation/DependencyManager.swift b/Applite/Utilities/Brew Installation/DependencyManager.swift index d0bbc4d..595ed17 100755 --- a/Applite/Utilities/Brew Installation/DependencyManager.swift +++ b/Applite/Utilities/Brew Installation/DependencyManager.swift @@ -97,18 +97,27 @@ struct DependencyManager { try await Shell.runAsync("curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C \(BrewPaths.appBrewDirectory.quotedPath())") + // Set selected Homebrew path to Applite's installation + BrewPaths.selectedBrewOption = .appPath + Self.logger.info("Brew install done") } - static func detectHomebrew() async -> BrewPaths.PathOption? { + static func detectHomebrew(setPathOption: Bool) async -> BrewPaths.PathOption? { async let appleSilicon = BrewPaths.isBrewPathValid(at: BrewPaths.getBrewExectuablePath(for: .defaultAppleSilicon)) async let intel = BrewPaths.isBrewPathValid(at: BrewPaths.getBrewExectuablePath(for: .defaultIntel)) if await appleSilicon { + if setPathOption { + BrewPaths.selectedBrewOption = .defaultAppleSilicon + } return .defaultAppleSilicon } if await intel { + if setPathOption { + BrewPaths.selectedBrewOption = .defaultIntel + } return .defaultIntel } diff --git a/Applite/Views/Setup/SetupView.swift b/Applite/Views/Setup/SetupView.swift index a614377..7c7dbfb 100755 --- a/Applite/Views/Setup/SetupView.swift +++ b/Applite/Views/Setup/SetupView.swift @@ -83,11 +83,7 @@ struct SetupView: View { } } .task { - detectedBrewInstallation = await DependencyManager.detectHomebrew() - - if let brewInstallation = detectedBrewInstallation { - BrewPaths.selectedBrewOption = brewInstallation - } + detectedBrewInstallation = await DependencyManager.detectHomebrew(setPathOption: true) } } }