Skip to content

Instantly share code, notes, and snippets.

@joshmanders

joshmanders/cask

Last active Feb 2, 2017
Embed
What would you like to do?
Homebrew Cask Upgrade
#!/usr/bin/env bash
readonly local caskroom="/usr/local/Caskroom"
upgrade () {
casks=($(brew cask list))
for cask in ${casks[@]}; do
current="$(brew cask info ${cask} | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
installed=($(ls ${caskroom}/${cask}))
if (! [[ " ${installed[@]} " == *" ${current} "* ]]); then
echo "Upgrading ${cask} to v${current}."
(set -x; brew cask install ${cask} --force; rm -rf ${caskroom}/${cask}/${installed[@]})
else
echo "${cask}@${current} already installed."
fi
done
}
main () {
local args=("$@")
case "$1" in
upgrade) upgrade "${args[@]}" ;;
*) brew cask "${args[@]}" ;;
esac
}
main "$@"
@ibrokemypie

This comment has been minimized.

Copy link

@ibrokemypie ibrokemypie commented Dec 7, 2016

does this support upgrading a single cask supplied as an arg?

@joshmanders

This comment has been minimized.

Copy link
Owner Author

@joshmanders joshmanders commented Feb 2, 2017

@ibrokemypie sorry I missed this comment, no it doesn't. It just loops through and updates all casks like brew upgrade does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.