Apple - Brew cask: I would like to check if the package/formula is already installed through brew or other means
I assume you know the name of the application. Then just test for existence of the application
if [[ ! -d "/Applications/APP-TO-CHECK.app" ]]; then
# install APP-TO-CHECK
fi