From 78a5e3fadf8552d8308e97ec0d3073c0671721fe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 31 Jul 2014 19:27:58 -0700 Subject: [PATCH] Attempt to improve `nvm copy-packages` --- nvm.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nvm.sh b/nvm.sh index aa46581..5389b2d 100644 --- a/nvm.sh +++ b/nvm.sh @@ -726,17 +726,15 @@ nvm() { nvm help return 127 fi - VERSION=`nvm_version $2` + VERSION=$(nvm_version "$2") local ROOT - ROOT=`(nvm use $VERSION && npm -g root)` - local ROOTDEPTH - ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1)) + ROOT=$(nvm use $VERSION && npm -g root) # declare local INSTALLS first, otherwise it doesn't work in zsh local INSTALLS - INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` + INSTALLS=$(nvm use $VERSION > /dev/null && npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | xargs) - npm install -g ${INSTALLS[@]} + npm install -g --quiet $INSTALLS ;; "clear-cache" ) rm -f $NVM_DIR/v* 2>/dev/null