Make `nvm copy-packages system` work.

master
Jordan Harband 2014-09-05 00:43:12 -07:00
parent ff1781b95d
commit 687df82107
1 changed files with 11 additions and 3 deletions

10
nvm.sh
View File

@ -801,10 +801,18 @@ nvm() {
return 2
fi
local INSTALLS
if [ "$PROVIDED_VERSION" = "system" ]; then
if ! nvm_has_system_node; then
echo 'No system version of node detected.' >&2
return 3
fi
INSTALLS=$(nvm deactivate > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
else
local VERSION
VERSION="$(nvm_version "$PROVIDED_VERSION")"
local INSTALLS
INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
fi
echo "$INSTALLS" | xargs npm install -g --quiet
;;