Created
February 11, 2022 10:40
-
-
Save kkirsche/c0da32873ef2cbd94996617677369c90 to your computer and use it in GitHub Desktop.
ASDF Version Checker / Updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu -o pipefail; | |
function check { | |
PLUGINS=$(asdf plugin list) | |
echo "Plugin Current Latest" | |
for plugin in ${PLUGINS}; do | |
LATEST_VERSION=$(asdf latest ${plugin}) | |
CURRENT_VERSION=$(asdf current ${plugin}| perl -lne 'print $& if /((\d+\.){2}\d+(-otp-\d+)?)/') | |
if [[ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]]; then | |
echo "${plugin} ${CURRENT_VERSION} ${LATEST_VERSION}" | |
fi | |
done | |
} | |
function update { | |
PLUGINS=$(asdf plugin list) | |
for plugin in ${PLUGINS}; do | |
if [[ ${plugin} == "nodejs" ]]; then | |
continue | |
fi | |
LATEST_VERSION=$(asdf latest ${plugin}) | |
CURRENT_VERSION=$(asdf current ${plugin}| perl -lne 'print $& if /((\d+\.){2}\d+(-otp-\d+)?)/') | |
if [[ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]]; then | |
echo "Installing ${plugin} ${LATEST_VERSION}" | |
asdf install ${plugin} ${LATEST_VERSION} | |
echo "Setting global ${plugin} version to ${LATEST_VERSION}" | |
asdf global ${plugin} ${LATEST_VERSION} | |
echo "Uninstalling ${plugin} ${CURRENT_VERSION}" | |
asdf uninstall ${plugin} ${CURRENT_VERSION} | |
fi | |
done | |
} | |
echo "Checking for outdated versions…" | |
check | column -t -s' ' | |
echo "Updating outdated versions…" | |
update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment