Skip to content

Commit

Permalink
Set brew path option after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 11, 2025
1 parent 5a9f6c3 commit 0a38dc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 10 additions & 1 deletion Applite/Utilities/Brew Installation/DependencyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 1 addition & 5 deletions Applite/Views/Setup/SetupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 0a38dc5

Please sign in to comment.