Remove duplicate code in nvm_npm_global_modules()

No matter what's the result of the condition here, the path is the same.
Peter Dave Hello 2018-02-05 06:21:33 +08:00
parent f290ccf1d5
commit bb803492d8
1 changed files with 1 additions and 5 deletions

6
nvm.sh
View File

@ -2077,11 +2077,7 @@ nvm_npm_global_modules() {
local NPMLIST local NPMLIST
local VERSION local VERSION
VERSION="$1" VERSION="$1"
if [ "_$VERSION" = "_system" ]; then NPMLIST=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 2> /dev/null | command sed 1,1d)
NPMLIST=$(nvm use system > /dev/null && npm list -g --depth=0 2> /dev/null | command sed 1,1d)
else
NPMLIST=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 2> /dev/null | command sed 1,1d)
fi
local INSTALLS local INSTALLS
INSTALLS=$(nvm_echo "$NPMLIST" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs) INSTALLS=$(nvm_echo "$NPMLIST" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)