mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 14:43:39 +00:00
feat(uninstall): enhance brew UX and auto-cleanup dependencies
- Auto-run 'brew autoremove' after uninstalling casks - Fix spinner interference during brew operations - Add safety check for cask token detection
This commit is contained in:
@@ -395,6 +395,8 @@ batch_uninstall_applications() {
|
|||||||
local used_brew_successfully=false
|
local used_brew_successfully=false
|
||||||
if [[ -z "$reason" ]]; then
|
if [[ -z "$reason" ]]; then
|
||||||
if [[ "$is_brew_cask" == "true" && -n "$cask_name" ]]; then
|
if [[ "$is_brew_cask" == "true" && -n "$cask_name" ]]; then
|
||||||
|
# Stop spinner before brew output
|
||||||
|
[[ -t 1 ]] && stop_inline_spinner
|
||||||
# Use brew_uninstall_cask helper (handles env vars, timeout, verification)
|
# Use brew_uninstall_cask helper (handles env vars, timeout, verification)
|
||||||
if brew_uninstall_cask "$cask_name" "$app_path"; then
|
if brew_uninstall_cask "$cask_name" "$app_path"; then
|
||||||
used_brew_successfully=true
|
used_brew_successfully=true
|
||||||
@@ -562,11 +564,17 @@ batch_uninstall_applications() {
|
|||||||
print_summary_block "$title" "${summary_details[@]}"
|
print_summary_block "$title" "${summary_details[@]}"
|
||||||
printf '\n'
|
printf '\n'
|
||||||
|
|
||||||
# Suggest brew autoremove if Homebrew casks were successfully uninstalled
|
# Auto-run brew autoremove if Homebrew casks were uninstalled
|
||||||
if [[ $brew_apps_removed -gt 0 ]]; then
|
if [[ $brew_apps_removed -gt 0 ]]; then
|
||||||
echo -e " ${GRAY}Tip: Run ${NC}brew autoremove${GRAY} to clean up orphaned dependencies${NC}"
|
local autoremove_output removed_count
|
||||||
|
autoremove_output=$(HOMEBREW_NO_ENV_HINTS=1 brew autoremove 2>/dev/null) || true
|
||||||
|
removed_count=$(printf '%s\n' "$autoremove_output" | grep -c "^Uninstalling" || true)
|
||||||
|
removed_count=${removed_count:-0}
|
||||||
|
if [[ $removed_count -gt 0 ]]; then
|
||||||
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Cleaned $removed_count orphaned brew dependencies"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Clean up Dock entries for uninstalled apps.
|
# Clean up Dock entries for uninstalled apps.
|
||||||
if [[ $success_count -gt 0 ]]; then
|
if [[ $success_count -gt 0 ]]; then
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ _detect_cask_via_caskroom_search() {
|
|||||||
done < <(find "$room" -maxdepth 3 -name "$app_bundle_name" 2>/dev/null)
|
done < <(find "$room" -maxdepth 3 -name "$app_bundle_name" 2>/dev/null)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Need at least one token
|
||||||
|
((${#tokens[@]} > 0)) || return 1
|
||||||
|
|
||||||
# Deduplicate and check count
|
# Deduplicate and check count
|
||||||
local -a uniq
|
local -a uniq
|
||||||
IFS=$'\n' read -r -d '' -a uniq < <(printf '%s\n' "${tokens[@]}" | sort -u && printf '\0') || true
|
IFS=$'\n' read -r -d '' -a uniq < <(printf '%s\n' "${tokens[@]}" | sort -u && printf '\0') || true
|
||||||
|
|||||||
Reference in New Issue
Block a user