-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·98 lines (83 loc) · 2.47 KB
/
uninstall.sh
File metadata and controls
executable file
·98 lines (83 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
INSTALL_DIR="${WP_MD_INSTALL_DIR:-$HOME/.wp-md}"
BIN_DIR="${WP_MD_BIN_DIR:-$HOME/.local/bin}"
info() {
echo -e "${BLUE}INFO${NC} $1"
}
success() {
echo -e "${GREEN}SUCCESS${NC} $1"
}
warn() {
echo -e "${YELLOW}WARN${NC} $1"
}
error() {
echo -e "${RED}ERROR${NC} $1"
}
echo -e "${BLUE}"
echo "╔══════════════════════════════════════════╗"
echo "║ wp-md uninstaller ║"
echo "╚══════════════════════════════════════════╝"
echo -e "${NC}"
# Check for npm global installation
if command -v npm &> /dev/null; then
NPM_GLOBAL=$(npm root -g 2>/dev/null || echo "")
if [ -n "$NPM_GLOBAL" ] && [ -d "$NPM_GLOBAL/wp-md" ]; then
info "Found npm global installation"
read -p "Remove npm global package? [Y/n]: " remove_npm
remove_npm=${remove_npm:-Y}
if [[ "$remove_npm" =~ ^[Yy]$ ]]; then
if npm uninstall -g wp-md 2>/dev/null; then
success "Removed npm global package"
else
warn "Trying with sudo..."
sudo npm uninstall -g wp-md && success "Removed npm global package"
fi
fi
fi
fi
# Check for local installation
if [ -d "$INSTALL_DIR" ]; then
info "Found local installation at $INSTALL_DIR"
read -p "Remove local installation? [Y/n]: " remove_local
remove_local=${remove_local:-Y}
if [[ "$remove_local" =~ ^[Yy]$ ]]; then
rm -rf "$INSTALL_DIR"
success "Removed $INSTALL_DIR"
fi
fi
# Check for symlink
if [ -L "$BIN_DIR/wp-md" ]; then
info "Found symlink at $BIN_DIR/wp-md"
rm "$BIN_DIR/wp-md"
success "Removed symlink"
fi
# Note about PATH
SHELL_NAME=$(basename "$SHELL")
case "$SHELL_NAME" in
bash)
PROFILE="$HOME/.bashrc"
[ -f "$HOME/.bash_profile" ] && PROFILE="$HOME/.bash_profile"
;;
zsh)
PROFILE="$HOME/.zshrc"
;;
fish)
PROFILE="$HOME/.config/fish/config.fish"
;;
*)
PROFILE="$HOME/.profile"
;;
esac
if grep -q "wp-md" "$PROFILE" 2>/dev/null; then
warn "PATH entry found in $PROFILE"
echo "You may want to manually remove the wp-md PATH entry"
fi
echo ""
success "wp-md has been uninstalled"