Skip to content

Commit

Permalink
[Fix] Prevent install/link when no packages found, fix #1744
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Feb 27, 2018
1 parent 5fc8bd9 commit 4d524df
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions nvm.sh
Expand Up @@ -3339,19 +3339,27 @@ nvm() {
LINKS="${NPMLIST##* //// }"

nvm_echo "Reinstalling global packages from $VERSION..."
nvm_echo "$INSTALLS" | command xargs npm install -g --quiet
if [ -n "${INSTALLS}" ]; then
nvm_echo "$INSTALLS" | command xargs npm install -g --quiet
else
nvm_echo "No global packages found..."
fi

nvm_echo "Linking global packages from $VERSION..."
(
set -f; IFS='
if [ -n "${LINKS}" ]; then
(
set -f; IFS='
' # necessary to turn off variable expansion except for newlines
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(nvm_cd "$LINK" && npm link)
fi
done
)
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(nvm_cd "$LINK" && npm link)
fi
done
)
else
nvm_echo "No global packages found..."
fi
;;
"clear-cache" )
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null
Expand Down

0 comments on commit 4d524df

Please sign in to comment.