Browse Source

Fixes issue 232

Fixes issue 232 that occurs in at least bash v4.2.25 where "nvm ls" returns "N/A" no matter how many versions of node have been installed.  The fix uses a combination of the find, tr and basename commands instead of basename only.  Tested in bash v3.2.48 and v4.2.25 and zsh v4.3.11.
master
Donovan James King 12 years ago
parent
commit
bc04ed3ece
  1. 5
      nvm.sh

5
nvm.sh

@ -79,7 +79,10 @@ nvm_ls() @@ -79,7 +79,10 @@ nvm_ls()
if [[ "$PATTERN" == v?*.?*.?* ]]; then
VERSIONS="$PATTERN"
else
VERSIONS=`nvm_set_nullglob; basename $NVM_DIR/v${PATTERN}* 2>/dev/null | sort -t. -k 1.2,1n -k 2,2n -k 3,3n`
VERSIONS=`find $NVM_DIR -type d -name "v$PATTERN*" -print \
| tr '\n' '\0' \
| xargs -0 -n 1 basename 2>/dev/null \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
if [ ! "$VERSIONS" ]; then
echo "N/A"

Loading…
Cancel
Save