Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: walkah/nvm
base: b5014a86f2
...
head fork: walkah/nvm
compare: 33bfe96da1
Checking mergeability… Don't worry, you can still create the pull request.
  • 12 commits
  • 2 files changed
  • 0 commit comments
  • 6 contributors
Commits on Nov 04, 2011
@luciananobii luciananobii Fixed incorrect sorting of versions 6f99471
@symposion symposion Rewrote version listing system
Now sorts correctly in all instances and prints highlights
even in sorted views. Also will output a list of matching versions
for commands of the form nvm ls 0.4* rather than just printing one
version. nvm version 0.4 still prints the single latest matching
version, however.
fda6e7f
Commits on Jan 27, 2012
@symposion symposion Merge remote-tracking branch 'upstream/master' b2683fd
Commits on Feb 06, 2012
@creationix creationix Merge pull request #65 from symposion/master
Fix for incorrect version sorting
1eaf6e2
Commits on Feb 19, 2012
Chakrit Wichian `nvm version` and `nvm ls` not correctly reporting current version on…
… both zsh and bash.
a49f771
Commits on Feb 20, 2012
@creationix creationix Merge pull request #102 from chakrit/patch-1
`nvm version` and `nvm ls` not correctly reporting current version.
293061b
Commits on Feb 24, 2012
@prozacgod prozacgod Removed default check for curl, and placed it into nvm function
This fixes issue with curl not being installed before nvm is initially sourced
and then curl subsequently being installed.

removed creation of global curl function (after error detected) which
overwrites the system tool, preventing execution of later installed
curl binary
7c3af21
@prozacgod prozacgod changed the function to place the curl requirement where it belongs 45051f4
Commits on Feb 27, 2012
@creationix creationix Merge pull request #104 from prozacgod/master
NVM "need curl to proceed"
dcd2929
Commits on Mar 07, 2012
@elf-pavlik elf-pavlik added note about solution to problem with version of python on system…
…s like Arch Linux
0dd0224
@creationix creationix Merge pull request #105 from elf-pavlik/master
added note to README with solution to problem with version of python on some systems
60892c7
Commits on Mar 08, 2012
@walkah merge creationix/master 33bfe96
Showing with 58 additions and 33 deletions.
  1. +6 −0 README.markdown
  2. +52 −33 nvm.sh
View
6 README.markdown
@@ -23,6 +23,7 @@ To download, compile, and install the v0.4.1 release of node, do this:
nvm install v0.4.1
+
And then in any new shell just use the installed version:
nvm use v0.4.1
@@ -52,3 +53,8 @@ If you try to install a node version and the installation fails, be sure to dele
Where's my 'sudo node'? Checkout this link:
https://github.com/creationix/nvm/issues/43
+
+on Arch Linux and other systems using python3 by default, before running *install* you need to
+
+ export PYTHON=python2
+
View
85 nvm.sh
@@ -10,44 +10,61 @@ if [ ! -d "$NVM_DIR" ]; then
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd)
fi
-# Emulate curl with wget, if necessary
-if [ ! `which curl` ]; then
- NOCURL='nocurl'
- curl() { echo 'Need curl to proceed.' >&2; }
-fi
-
# Expand a version using the version cache
nvm_version()
{
PATTERN=$1
- VERSION=''
+ # The default version is the current one
+ if [ ! "$PATTERN" ]; then
+ PATTERN='current'
+ fi
+
+ VERSION=`nvm_ls $PATTERN | tail -n1`
+ echo "$VERSION"
+
+ if [ "$VERSION" = 'N/A' ]; then
+ return 13
+ fi
+}
+
+nvm_ls()
+{
+ PATTERN=$1
+ VERSIONS=''
+ if [ "$PATTERN" = 'current' ]; then
+ echo `node -v 2>/dev/null`
+ return
+ fi
+
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
nvm_version `cat $NVM_DIR/alias/$PATTERN`
return
fi
# If it looks like an explicit version, don't do anything funny
if [[ "$PATTERN" == v?*.?*.?* ]]; then
- VERSION="$PATTERN"
- fi
- # The default version is the current one
- if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then
- VERSION=`node -v 2>/dev/null`
- fi
- if [ "$PATTERN" = 'all' ]; then
- (cd $NVM_DIR; \ls -dG v* 2>/dev/null || echo "N/A")
- return
- fi
- if [ ! "$VERSION" ]; then
- VERSION=`(cd $NVM_DIR; \ls -d v${~PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1`
+ VERSIONS="$PATTERN"
+ else
+ VERSIONS=`(cd $NVM_DIR; \ls -d v${~PATTERN}* 2>/dev/null) | sort -t. -k 1.2,1n -k 2,2n -k 3,3n`
fi
- if [ ! "$VERSION" ]; then
+ if [ ! "$VERSIONS" ]; then
echo "N/A"
- return 13
- elif [ -e "$NVM_DIR/$VERSION" ]; then
- (cd $NVM_DIR; \ls -dG "$VERSION")
- else
- echo "$VERSION"
+ return
fi
+ echo "$VERSIONS"
+ return
+}
+
+print_versions()
+{
+ OUTPUT=''
+ for VERSION in $1; do
+ PADDED_VERSION=`printf '%10s' $VERSION`
+ if [[ -d "$NVM_DIR/$VERSION" ]]; then
+ PADDED_VERSION="\033[0;34m$PADDED_VERSION\033[0m"
+ fi
+ OUTPUT="$OUTPUT\n$PADDED_VERSION"
+ done
+ echo -e "$OUTPUT" | column
}
nvm()
@@ -83,11 +100,14 @@ nvm()
echo
;;
"install" )
+ if [ ! `which curl` ]; then
+ echo 'NVM Needs curl to proceed.' >&2;
+ fi
+
if [ $# -ne 2 ]; then
nvm help
return
fi
- [ "$NOCURL" ] && curl && return
VERSION=`nvm_version $2`
[ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return
@@ -214,13 +234,12 @@ nvm()
$NVM_DIR/$VERSION/bin/node "${@:3}"
;;
"ls" | "list" )
- if [ $# -ne 1 ]; then
- nvm_version $2
- return
+ print_versions "`nvm_ls $2`"
+ if [ $# -eq 1 ]; then
+ echo -ne "current: \t"; nvm_version current
+ nvm alias
fi
- nvm_version all
- echo -ne "current: \t"; nvm_version current
- nvm alias
+ return
;;
"alias" )
mkdir -p $NVM_DIR/alias
@@ -275,7 +294,7 @@ nvm()
echo "Cache cleared."
;;
"version" )
- nvm_version $2
+ print_versions "`nvm_version $2`"
;;
* )
nvm help

No commit comments for this range

Something went wrong with that request. Please try again.