Skip to content

Commit

Permalink
Make brew_is_upgradable mac function more robust
Browse files Browse the repository at this point in the history
Rely on logic of `brew outdated` to decide whether a brew is upgradable.

Fixes thoughtbot#276 and thoughtbot#282:
* thoughtbot#276
* thoughtbot#282
  • Loading branch information
gohanlon committed Aug 31, 2014
1 parent 5754363 commit 6b7c8e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions mac
Expand Up @@ -55,10 +55,8 @@ brew_is_installed() {
brew_is_upgradable() {
local NAME=$(brew_expand_alias "$1")

local INSTALLED=$(brew ls --versions "$NAME" | awk '{print $NF}')
local LATEST=$(brew info "$NAME" 2>/dev/null | head -1 | awk '{gsub(/,/, ""); print $3}')

[ "$INSTALLED" != "$LATEST" ]
brew outdated --quiet "$NAME" >/dev/null
[[ $? -ne 0 ]]
}

brew_expand_alias() {
Expand Down
6 changes: 2 additions & 4 deletions mac-components/mac-functions
Expand Up @@ -17,10 +17,8 @@ brew_is_installed() {
brew_is_upgradable() {
local NAME=$(brew_expand_alias "$1")

local INSTALLED=$(brew ls --versions "$NAME" | awk '{print $NF}')
local LATEST=$(brew info "$NAME" 2>/dev/null | head -1 | awk '{gsub(/,/, ""); print $3}')

[ "$INSTALLED" != "$LATEST" ]
brew outdated --quiet "$NAME" >/dev/null
[[ $? -ne 0 ]]
}

brew_expand_alias() {
Expand Down

0 comments on commit 6b7c8e7

Please sign in to comment.