Merge pull request #388 from koenpunt/small-fixes

Use NVM_ prefix for non local variables
master
Jordan Harband 2014-03-23 11:56:09 -07:00
commit 7c45d62b37
1 changed files with 10 additions and 10 deletions

20
nvm.sh
View File

@ -5,7 +5,7 @@
# Implemented by Tim Caswell <tim@creationix.com> # Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney # with much bash help from Matthew Ranney
SCRIPT_SOURCE="$_" NVM_SCRIPT_SOURCE="$_"
nvm_has() { nvm_has() {
type "$1" > /dev/null 2>&1 type "$1" > /dev/null 2>&1
@ -22,11 +22,11 @@ fi
# Auto detect the NVM_DIR when not set # Auto detect the NVM_DIR when not set
if [ -z "$NVM_DIR" ]; then if [ -z "$NVM_DIR" ]; then
if [ -n "$BASH_SOURCE" ]; then if [ -n "$BASH_SOURCE" ]; then
SCRIPT_SOURCE="${BASH_SOURCE[0]}" NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi fi
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${SCRIPT_SOURCE:-$0}") > /dev/null && pwd) export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && pwd)
fi fi
unset SCRIPT_SOURCE 2> /dev/null unset NVM_SCRIPT_SOURCE 2> /dev/null
# Setup mirror location if not already set # Setup mirror location if not already set
@ -37,8 +37,8 @@ fi
# Obtain nvm version from rc file # Obtain nvm version from rc file
nvm_rc_version() { nvm_rc_version() {
if [ -e .nvmrc ]; then if [ -e .nvmrc ]; then
RC_VERSION=`cat .nvmrc | head -n 1` NVM_RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$RC_VERSION>" echo "Found .nvmrc files with version <$NVM_RC_VERSION>"
fi fi
} }
@ -158,7 +158,7 @@ nvm_print_versions() {
local FORMAT local FORMAT
local CURRENT=`nvm_version current` local CURRENT=`nvm_version current`
echo "$1" | while read VERSION; do echo "$1" | while read VERSION; do
if [ "$VERSION" == "$CURRENT" ]; then if [ "$VERSION" = "$CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m' FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$NVM_DIR/$VERSION" ]; then elif [ -d "$NVM_DIR/$VERSION" ]; then
FORMAT='\033[0;34m%12s\033[0m' FORMAT='\033[0;34m%12s\033[0m'
@ -358,7 +358,7 @@ nvm() {
"uninstall" ) "uninstall" )
[ $# -ne 2 ] && nvm help && return [ $# -ne 2 ] && nvm help && return
PATTERN=`nvm_format_version $2` PATTERN=`nvm_format_version $2`
if [[ $PATTERN == `nvm_version` ]]; then if [ "$PATTERN" = `nvm_version` ]; then
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." echo "nvm: Cannot uninstall currently-active node version, $PATTERN."
return 1 return 1
fi fi
@ -413,8 +413,8 @@ nvm() {
fi fi
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
nvm_rc_version nvm_rc_version
if [ -n "$RC_VERSION" ]; then if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $RC_VERSION` VERSION=`nvm_version $NVM_RC_VERSION`
fi fi
else else
VERSION=`nvm_version $2` VERSION=`nvm_version $2`