Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-09-04 10:59:08 +0400
committerisaacs <i@izs.me>2011-09-04 10:59:08 +0400
commitb178f2cc19c50f87110bbd76fb736b04bdcd8b1c (patch)
tree0354337938eb625753b343d9091be7c3655cdd8c /scripts
parent04d79143f1ae09519e46d1f80c65e66c9cbc6e6b (diff)
Update clean-old script to show list that will be deleted first
Diffstat (limited to 'scripts')
-rw-r--r--scripts/clean-old.sh102
1 files changed, 59 insertions, 43 deletions
diff --git a/scripts/clean-old.sh b/scripts/clean-old.sh
index 98b44e711..b580a7d73 100644
--- a/scripts/clean-old.sh
+++ b/scripts/clean-old.sh
@@ -52,37 +52,8 @@ done
packages=`echo $packages`
-echo ""
-echo "This script will find and eliminate any shims, symbolic"
-echo "links, and other cruft that was installed by npm 0.x."
-echo ""
-
-if [ "x$packages" != "x" ]; then
- echo "The following packages appear to have been installed with"
- echo "an old version of npm, and will be removed forcibly:"
- for pkg in $packages; do
- echo " $pkg"
- done
- echo "Make a note of these. You may want to install them"
- echo "with npm 1.0 when this process is completed."
- echo ""
-fi
-
-OK=
-if [ "x$1" = "x-y" ]; then
- OK="yes"
-fi
-
-while [ "$OK" != "y" ] && [ "$OK" != "yes" ] && [ "$OK" != "no" ]; do
- echo "Is this OK? enter 'yes' or 'no' "
- read OK
-done
-if [ "$OK" = "no" ]; then
- echo "Aborting"
- exit 1
-fi
-
-filelist=""
+filelist=()
+fid=0
for prefix in $PREFIXES; do
# remove any links into the .npm dir, or links to
@@ -92,8 +63,8 @@ for prefix in $PREFIXES; do
target=`$readlink $file | grep '/\.npm/'`
if [ "x$target" != "x" ]; then
# found one!
- echo rm -rf "$file"
- rm -rf "$file"
+ filelist[$fid]="$file"
+ let 'fid++'
# also remove any symlinks to this file.
base=`basename "$file"`
base=`echo "$base" | awk -F@ '{print $1}'`
@@ -102,8 +73,8 @@ for prefix in $PREFIXES; do
| while read l; do
target=`$readlink "$l" | grep "$base"`
if [ "x$target" != "x" ]; then
- echo rm -rf $l
- rm -rf $l
+ filelist[$fid]="$1"
+ let 'fid++'
fi
done
fi
@@ -115,29 +86,74 @@ for prefix in $PREFIXES; do
find $prefix/$folder -type f \
| xargs grep -sl '// generated by npm' \
| while read file; do
- echo rm -rf $file
- rm -rf $file
+ filelist[$fid]="$file"
+ let 'fid++'
done
done
# now remove the package modules, and the .npm folder itself.
if [ "x$packages" != "x" ]; then
for pkg in $packages; do
- echo rm -rf $prefix/lib/node/$pkg
- rm -rf $prefix/lib/node/$pkg
- echo rm -rf $prefix/lib/node/$pkg\@*
- rm -rf $prefix/lib/node/$pkg\@*
+ filelist[$fid]="$prefix/lib/node/$pkg"
+ let 'fid++'
+ for i in $prefix/lib/node/$pkg\@*; do
+ filelist[$fid]="$i"
+ let 'fid++'
+ done
done
fi
for folder in lib/node/.npm lib/npm share/npm; do
if [ -d $prefix/$folder ]; then
- echo rm -rf $prefix/$folder
- rm -rf $prefix/$folder
+ filelist[$fid]="$prefix/$folder"
+ let 'fid++'
fi
done
done
+# now actually clean, but only if there's anything TO clean
+if [ "${#filelist[@]}" -gt 0 ]; then
+ echo ""
+ echo "This script will find and eliminate any shims, symbolic"
+ echo "links, and other cruft that was installed by npm 0.x."
+ echo ""
+
+ if [ "x$packages" != "x" ]; then
+ echo "The following packages appear to have been installed with"
+ echo "an old version of npm, and will be removed forcibly:"
+ for pkg in $packages; do
+ echo " $pkg"
+ done
+ echo "Make a note of these. You may want to install them"
+ echo "with npm 1.0 when this process is completed."
+ echo ""
+ fi
+
+ OK=
+ if [ "x$1" = "x-y" ]; then
+ OK="yes"
+ fi
+
+ while [ "$OK" != "y" ] && [ "$OK" != "yes" ] && [ "$OK" != "no" ]; do
+ echo "Is this OK?"
+ echo " enter 'yes' or 'no'"
+ echo " or 'show' to see a list of files "
+ read OK
+ if [ "x$OK" = "xshow" ] || [ "x$OK" = "xs" ]; then
+ for i in "${filelist[@]}"; do
+ echo "$i"
+ done
+ fi
+ done
+ if [ "$OK" = "no" ]; then
+ echo "Aborting"
+ exit 1
+ fi
+ for i in "${filelist[@]}"; do
+ rm -rf "$i"
+ done
+fi
+
echo ""
echo 'All clean!'