Skip to content
Myr

Merge pull request #466 from creationix/nvm_ls_minor_versions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

nvm_ls minor versions

authored by Jordan Harband · committed by Jordan Harband · parents c49cb68, 83efa22 · Browse files · 2 files+39 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+39 added−6 removed

  • tests:+33 added−4 removed
  • other:+6 added−2 removed

2 files+39 added−6 removed

modified:test/fast/Listing versions/Running "nvm ls 0.2" should display only 0.2.x versions.+33 added-4 removed
1#!/bin/sh23mkdir ../../../v0.1.34mkdir ../../../v0.2.35mkdir ../../../v0.20.367. ../../../nvm.sh89die () { echo $@ ; exit 1; }1011# The result should contain only the appropriate version numbers.9nvm ls 0.2 | grep v0.2.3 &&10nvm ls 0.1 | grep -v v0.2.3 &&11nvm ls 0.1 | grep v0.1.3 &&12nvm ls v0.2 | grep v0.2.31213nvm ls 0.1 | grep 'v0.2.3' > /dev/null14if [ $? -eq 0 ]; then15 echo '"nvm ls 0.1" contained v0.2.3'16fi1718nvm ls 0.1 | grep 'v0.20.3' > /dev/null19if [ $? -eq 0 ]; then20 die '"nvm ls 0.1" contained v0.20.3'21fi2223nvm ls 0.1 | grep 'v0.1.3' > /dev/null24if [ $? -ne 0 ]; then25 die '"nvm ls 0.1" did not contain v0.1.3'26fi2728nvm ls 0.2 | grep 'v0.2.3' > /dev/null29if [ $? -ne 0 ]; then30 die '"nvm ls 0.2" did not contain v0.2.3'31fi3233nvm ls 0.2 | grep 'v0.20.3' > /dev/null34if [ $? -eq 0 ]; then35 die '"nvm ls 0.2" contained v0.20.3'36fi3738nvm ls 0.2 | grep 'v0.2.3' > /dev/null39if [ $? -ne 0 ]; then40 die '"nvm ls 0.2" did not contain v0.2.3'41fi
modified:nvm.sh+6 added-2 removed
151 unmodified lines
152 nvm_version `cat $NVM_DIR/alias/$PATTERN`153 return154 fi155 # If it looks like an explicit version, don't do anything funny156 if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then156 if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then157 if [ -d "$NVM_DIR/$PATTERN" ]; then158 VERSIONS="$PATTERN"159 fi160 else161 PATTERN=$(nvm_format_version $PATTERN)162 if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then163 PATTERN="$PATTERN."164 fi161 VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \165 VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \166 | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.'`167 fi168 if [ -z "$VERSIONS" ]; then169 echo "N/A"
521 unmodified lines