Merge pull request #436 from koenpunt/stderr

redirect output of errors to stderr
master
Jordan Harband 2014-06-16 16:37:31 -07:00
commit 9a28706688
3 changed files with 43 additions and 43 deletions

30
nvm.sh
View File

@ -181,7 +181,7 @@ nvm_checksum() {
echo 'Checksums empty' #missing in raspberry pi binary echo 'Checksums empty' #missing in raspberry pi binary
return return
else else
echo 'Checksums do not match.' echo 'Checksums do not match.' >&2
return 1 return 1
fi fi
} }
@ -308,7 +308,7 @@ nvm() {
fi fi
provided_version="$NVM_RC_VERSION" provided_version="$NVM_RC_VERSION"
fi fi
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return [ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." >&2 && return
VERSION=`nvm_remote_version $provided_version` VERSION=`nvm_remote_version $provided_version`
ADDITIONAL_PARAMETERS='' ADDITIONAL_PARAMETERS=''
@ -322,13 +322,13 @@ nvm() {
done done
if [ -d "$NVM_DIR/$VERSION" ]; then if [ -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION is already installed." echo "$VERSION is already installed." >&2
nvm use "$VERSION" nvm use "$VERSION"
return $? return $?
fi fi
if [ "$VERSION" = "N/A" ]; then if [ "$VERSION" = "N/A" ]; then
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2
return 3 return 3
fi fi
@ -395,10 +395,10 @@ nvm() {
if ! nvm_has "npm" ; then if ! nvm_has "npm" ; then
echo "Installing npm..." echo "Installing npm..."
if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher" echo "npm requires node v0.2.3 or higher" >&2
elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
echo "npm requires node v0.2.3 or higher" echo "npm requires node v0.2.3 or higher" >&2
else else
curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh
fi fi
@ -407,7 +407,7 @@ nvm() {
fi fi
fi fi
else else
echo "nvm: install $VERSION failed!" echo "nvm: install $VERSION failed!" >&2
return 1 return 1
fi fi
;; ;;
@ -415,12 +415,12 @@ nvm() {
[ $# -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." >&2
return 1 return 1
fi fi
VERSION=`nvm_version $PATTERN` VERSION=`nvm_version $PATTERN`
if [ ! -d $NVM_DIR/$VERSION ]; then if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed..." echo "$VERSION version is not installed..." >&2
return; return;
fi fi
@ -447,19 +447,19 @@ nvm() {
hash -r hash -r
echo "$NVM_DIR/*/bin removed from \$PATH" echo "$NVM_DIR/*/bin removed from \$PATH"
else else
echo "Could not find $NVM_DIR/*/bin in \$PATH" echo "Could not find $NVM_DIR/*/bin in \$PATH" >&2
fi fi
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"` export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
echo "$NVM_DIR/*/share/man removed from \$MANPATH" echo "$NVM_DIR/*/share/man removed from \$MANPATH"
else else
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" >&2
fi fi
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH" echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
else else
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2
fi fi
;; ;;
"use" ) "use" )
@ -483,7 +483,7 @@ nvm() {
VERSION=`nvm_version $2` VERSION=`nvm_version $2`
fi fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet" echo "$VERSION version is not installed yet" >&2
return 1 return 1
fi fi
# Strip other version from PATH # Strip other version from PATH
@ -542,7 +542,7 @@ nvm() {
fi fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then if [ ! -d "$NVM_DIR/$VERSION" ]; then
echo "$VERSION version is not installed yet" echo "$VERSION version is not installed yet" >&2
return; return;
fi fi
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
@ -601,7 +601,7 @@ nvm() {
"unalias" ) "unalias" )
mkdir -p $NVM_DIR/alias mkdir -p $NVM_DIR/alias
[ $# -ne 2 ] && nvm help && return 127 [ $# -ne 2 ] && nvm help && return 127
[ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" && return [ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" >&2 && return
rm -f $NVM_DIR/alias/$2 rm -f $NVM_DIR/alias/$2
echo "Deleted alias $2" echo "Deleted alias $2"
;; ;;

View File

@ -3,5 +3,5 @@
die () { echo $@ ; exit 1; } die () { echo $@ ; exit 1; }
. ../../nvm.sh . ../../nvm.sh
[ "$(nvm install invalid.invalid)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" [ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"

View File

@ -4,7 +4,7 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh . ../../../nvm.sh
[ "$(nvm install invalid.invalid)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" [ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
# Remove the stuff we're clobbering. # Remove the stuff we're clobbering.
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7 [ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7