Skip to content

Commit

Permalink
[fix] Remove version packages and tarballs if they already exist in `…
Browse files Browse the repository at this point in the history
…npm-update`. Fixes #5.
  • Loading branch information
indexzero committed May 24, 2013
1 parent 3b66bb4 commit d49b01a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions base/npm-manager/files/npm-uninstall
Expand Up @@ -4,6 +4,8 @@ PACKAGE=$1
# Get the version of the existing install
#
VERSION=`pkgver $HOME/$PACKAGE/package.json`
TARGET_PKG="$HOME/versions/$VERSION/$PACKAGE"
TARGET_TGZ="$HOME/versions/$VERSION/$PACKAGE.tgz"

#
# Move the existing package into place under $HOME/versions
Expand All @@ -13,9 +15,17 @@ if [ ! -d $HOME/versions/$VERSION ]; then
fi

if [ -d $HOME/$PACKAGE ]; then
mv $HOME/$PACKAGE $HOME/versions/$VERSION/$PACKAGE
if [ -d $TARGET_PKG ]; then
rm -rf $TARGET_PKG
fi

mv $HOME/$PACKAGE $TARGET_PKG
fi

if [ -f $HOME/$PACKAGE-$VERSION.tgz ]; then
mv $HOME/$PACKAGE-$VERSION.tgz $HOME/versions/$VERSION/$PACKAGE.tgz
if [ -d $TARGET_TGZ ]; then
rm -rf $TARGET_TGZ
fi

mv $HOME/$PACKAGE-$VERSION.tgz $TARGET_TGZ
fi

0 comments on commit d49b01a

Please sign in to comment.