Last active
April 22, 2024 02:06
-
-
Save developer-guy/4de4e2ff2eaa31633a0fef719c92eada to your computer and use it in GitHub Desktop.
Revisions
-
developer-guy revised this gist
Mar 14, 2021 . No changes.There are no files selected for viewing
-
developer-guy created this gist
Mar 14, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env sh function update() { for i in `asdf plugin list` do CURRENT_VERSION=`asdf current $i | awk '{print $2}'` LATEST_VERSION=`asdf latest $i` echo "Working with $i current version $CURRENT_VERSION but latest version is $LATEST_VERSION" if [[ $(semver_check $LATEST_VERSION $CURRENT_VERSION) -lt 0 ]]; then echo "Needs to update" asdf install $i $LATEST_VERSION echo "Prearing global value of $i is $LATEST_VERSION" asdf global $i $LATEST_VERSION else echo "No need to update $i." fi done } function semver_check() { # sort low->high then pick the last one (highest) local HV; HV=$(echo -e "$1\n$2" |sort -V |tail -1) # They're not the same and $1 is not the high version = -1 [[ "$1" != "$2" && "$1" != "$HV" ]] && echo -1 && return # 0 = they're the same; 1 = not the same [[ "$1" == "$2" ]]; echo $? } function main() { update } main