chore: make homebrew higher priority for upgrade banner

This commit is contained in:
Anton Panasenko
2026-01-28 13:56:44 -08:00
parent 7b34cad1b1
commit 266c5a8c80

View File

@@ -48,14 +48,14 @@ fn detect_update_action(
managed_by_npm: bool,
managed_by_bun: bool,
) -> Option<UpdateAction> {
if managed_by_npm {
Some(UpdateAction::NpmGlobalLatest)
} else if managed_by_bun {
Some(UpdateAction::BunGlobalLatest)
} else if is_macos
if is_macos
&& (current_exe.starts_with("/opt/homebrew") || current_exe.starts_with("/usr/local"))
{
Some(UpdateAction::BrewUpgrade)
} else if managed_by_npm {
Some(UpdateAction::NpmGlobalLatest)
} else if managed_by_bun {
Some(UpdateAction::BunGlobalLatest)
} else {
None
}
@@ -88,6 +88,15 @@ mod tests {
),
Some(UpdateAction::BrewUpgrade)
);
assert_eq!(
detect_update_action(
true,
std::path::Path::new("/opt/homebrew/bin/codex"),
true,
false
),
Some(UpdateAction::BrewUpgrade)
);
assert_eq!(
detect_update_action(
true,
@@ -97,5 +106,14 @@ mod tests {
),
Some(UpdateAction::BrewUpgrade)
);
assert_eq!(
detect_update_action(
true,
std::path::Path::new("/usr/local/bin/codex"),
false,
true
),
Some(UpdateAction::BrewUpgrade)
);
}
}