Skip to content

Commit

Permalink
fix: select correct legacy version (closes #358) (#359)
Browse files Browse the repository at this point in the history
* fix: select correct legacy version (closes #358)

* Allow macOS' sort to sort versions
  • Loading branch information
luzat authored Jul 30, 2024
1 parent fb44c90 commit c36e6f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ list_installed_versions() {
fi
}

# stolen from https://github.com/rbenv/ruby-build/pull/631/files#diff-fdcfb8a18714b33b07529b7d02b54f1dR942
sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' |
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}

resolve_legacy_version() {
local strategy="$1" query="$2"
local resolved=

case "$strategy" in
latest_installed)
_list() {
ASDF_NODEJS_SKIP_NODEBUILD_UPDATE=1 list_installed_versions nodejs
ASDF_NODEJS_SKIP_NODEBUILD_UPDATE=1 list_installed_versions nodejs | sort_versions
}
;;

Expand Down

0 comments on commit c36e6f0

Please sign in to comment.