From 4c8d3a70ea0ffef655976b4f7a70e5227948941d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ne=C5=A1et=C5=99il?= Date: Sat, 2 Jul 2011 09:14:48 -0700 Subject: [PATCH] Added copy-packages command --- nvm.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 39c950e..5d85e6c 100644 --- a/nvm.sh +++ b/nvm.sh @@ -89,6 +89,7 @@ nvm() echo " nvm sync Update the local cache of available versions" echo " nvm alias [] Show all aliases beginning with " echo " nvm alias Set an alias named pointing to " + echo " nvm copy-packages Install global NPM packages contained in to current version" echo echo "Example:" echo " nvm install v0.4.0 Install a specific version number" @@ -228,6 +229,16 @@ nvm() [ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`" [ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`" ;; + "copy-packages" ) + if [ $# -ne 2 ]; then + nvm help + return + fi + VERSION=`nvm_version $2` + ROOT=`nvm use $VERSION && npm -g root` + INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | grep -v npm | tr "\n" " "` + npm install -g $INSTALLS + ;; "clear-cache" ) rm -f $NVM_DIR/v* 2>/dev/null echo "Cache cleared." @@ -241,4 +252,4 @@ nvm() esac } -nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null +nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null \ No newline at end of file