brew.sh: communicate when autoupdate runs for long

This will ease user anxiety when `brew install foo' is typed but nothing
seems to happen.
This commit is contained in:
Zhiming Wang 2016-10-30 20:11:45 -04:00
parent 8d5df2ea87
commit 0ca697ad2f
No known key found for this signature in database
GPG Key ID: BBD31D4D110044B8

View File

@ -296,6 +296,13 @@ source "$HOMEBREW_LIBRARY/Homebrew/utils/analytics.sh"
setup-analytics setup-analytics
report-analytics-screenview-command report-analytics-screenview-command
# Let user know we're still updating Homebrew if brew update --preinstall
# exceeds 3 seconds.
update-preinstall-timer() {
sleep 3
echo 'Updating Homebrew...' >&2
}
update-preinstall() { update-preinstall() {
[[ -z "$HOMEBREW_HELP" ]] || return [[ -z "$HOMEBREW_HELP" ]] || return
[[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return [[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return
@ -306,7 +313,19 @@ update-preinstall() {
if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" ]] if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" ]]
then then
if [[ -z "$HOMEBREW_VERBOSE" ]]
then
update-preinstall-timer &
timer_pid=$!
fi
brew update --preinstall brew update --preinstall
if [[ -n "$timer_pid" ]]
then
kill "$timer_pid" 2>/dev/null
wait "$timer_pid" 2>/dev/null
fi
fi fi
# If brew update --preinstall did a migration then export the new locations. # If brew update --preinstall did a migration then export the new locations.