Make `nvm ls` support listing the "versions" directory when it's present.
parent
65c2435418
commit
5dd2d7e5d4
7
nvm.sh
7
nvm.sh
|
@ -229,8 +229,13 @@ nvm_ls() {
|
|||
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||
PATTERN="$PATTERN."
|
||||
fi
|
||||
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
|
||||
if [ -d "$(nvm_version_dir new)" ]; then
|
||||
VERSIONS=`find "$(nvm_version_dir new)/" "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
|
||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
|
||||
else
|
||||
VERSIONS=`find "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
|
||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
|
||||
fi
|
||||
fi
|
||||
if [ -z "$VERSIONS" ]; then
|
||||
echo "N/A"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
mkdir -p ../../../versions/v0.12.1
|
||||
mkdir ../../../v0.1.3
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory'
|
||||
nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory'
|
||||
|
|
@ -7,5 +7,6 @@ rmdir ../../../v0.2.3
|
|||
rmdir ../../../v0.3.1
|
||||
rmdir ../../../v0.3.3
|
||||
rmdir ../../../v0.3.9
|
||||
rmdir ../../../versions
|
||||
unalias nvm_has_system_node
|
||||
|
||||
|
|
Loading…
Reference in New Issue