Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #192 from gpad/nvmrc

Use .nvmrc if present
  • Loading branch information...
commit 0ec339e0403287c40221be2b871d1b4677706bfd 2 parents f605581 + 7226e5f
@creationix authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 nvm.sh
View
22 nvm.sh
@@ -16,6 +16,14 @@ if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
unsetopt nomatch 2>/dev/null
fi
+# Obtain nvm version from rc file
+function rc_nvm_version {
+ if [ -e .nvmrc ]; then
+ RC_VERSION=`cat .nvmrc | head -n 1`
+ echo "Found .nvmrc files with version <$RC_VERSION>"
+ fi
+}
+
# Expand a version using the version cache
nvm_version()
{
@@ -344,7 +352,19 @@ nvm()
fi
;;
"use" )
- if [ $# -ne 2 ]; then
+ if [ $# -eq 0 ]; then
+ nvm help
+ return
+ fi
+ if [ $# -eq 1 ]; then
+ rc_nvm_version
+ if [ ! -z $RC_VERSION ]; then
+ VERSION=`nvm_version $RC_VERSION`
+ fi
+ else
+ VERSION=`nvm_version $2`
+ fi
+ if [ -z $VERSION ]; then
nvm help
return
fi
Please sign in to comment.
Something went wrong with that request. Please try again.