Skip to content

Commit

Permalink
feat(mac): Add script to check whether asdf plugins exist for an inst…
Browse files Browse the repository at this point in the history
…alled brew tool
  • Loading branch information
kpatryk committed Oct 12, 2024
1 parent f3af004 commit 32b95f6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/macos/check_asdf_installer_exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# This script checks if there are any installed Homebrew casks or formulae
# that have corresponding plugins available in asdf.
#
# Steps:
# 1. Retrieve the list of all available asdf plugins and store them in an array.
# 2. Loop through the installed Homebrew casks and formulae.
# 3. For each installed item, check if there is a matching plugin in the asdf plugin list.
# 4. If a match is found, print the type (cask or formula) and the item name.

# Main script
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "This script is only supported on MacOS."
exit 1
fi

# Retrieve the list of all available asdf plugins
IFS=$'\n' read -rd '' -a asdf_plugins <<<"$(asdf plugin-list-all)"

# Loop through installed brew items
for type in casks formulae; do
for item in $(brew ls --$type); do
# Check if the item has a matching plugin in asdf
if [[ " ${asdf_plugins[*]} " == *" $item "* ]]; then
echo "Brew ${type^} has matching asdf plugin: $item"
fi
done
done

0 comments on commit 32b95f6

Please sign in to comment.