Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,18 @@ port() {
port=$((min_port + (sum % port_range)))

echo $port
}

# Prevent brew upgrade commands
brew() {
local command="$1"
shift

if [[ "$command" == "upgrade" ]] || [[ "$command" == "update" && "$*" == *"--greedy"* ]] || [[ "$command" == "update" && "$*" == *"upgrade"* ]]; then
echo "⛔️ BREW UPGRADE BLOCKED: This command has been disabled to prevent breaking your system, it will break Postgres & Meilisearch and you will waste a lot of time fixing them."
echo "If you really need to upgrade packages, use 'command brew $command $*' to bypass this protection."
return 1
else
command brew "$command" "$@"
fi
}