Skip to content
Permalink
Browse files

Make npm uninstall script interctive - also runs on npm update (#625)

Previously while updating through `npm update`, It would automatically 
call `uninstall` script and remove user configuration, this change makes
that process interactive.

Use POSIX compliant sed for in-place user config modification.
  • Loading branch information...
Runrioter authored and salmanulfarzy committed Mar 5, 2019
1 parent afb644d commit 916d437772d7a32d05c859149a1bc7980a4c1c38
Showing with 14 additions and 7 deletions.
  1. +14 −7 scripts/uninstall.sh
@@ -80,13 +80,20 @@ main() {

# Remove Spaceship from .zshrc
if grep -q "spaceship" "$ZSHRC"; then
info "Removing Spaceship from ~/.zshrc"
# Remove enabling statements from ~/.zshrc
sed -i '' '/^# Set Spaceship ZSH as a prompt$/d' $ZSHRC
sed -i '' '/^autoload -U promptinit; promptinit$/d' $ZSHRC
sed -i '' '/^prompt spaceship$/d' $ZSHRC
# Remove Spaceship configuration
sed -i '' '/^SPACESHIP_.*$/d' $ZSHRC
read "answer?Would you like to remove you Spaceship ZSH configuration from .zshrc? (y/N)"
if [[ 'y' == ${answer:l} ]]; then
info "Removing Spaceship from ~/.zshrc"
# Remove enabling statements from ~/.zshrc
# and remove Spaceship configuration
# Note: SPACESHIP_RPROMPT_ORDER and SPACESHIP_PROMPT_ORDER configuration may have multiple lines
# which are grouped by `(`, `)`
sed '/^# Set Spaceship ZSH as a prompt$/d' "$ZSHRC" | \
sed '/^autoload -U promptinit; promptinit$/d' | \
sed '/^prompt spaceship$/d' | \
sed -E '/^SPACESHIP_R?PROMPT_ORDER=\([^)]*$/,/^[^(]*)/d' | \
sed '/^SPACESHIP_.*$/d' > "$ZSHRC.bak" && \
mv -- "$ZSHRC.bak" "$ZSHRC"
fi
else
warn "Spaceship configuration not found in ~/.zshrc!"
fi

0 comments on commit 916d437

Please sign in to comment.
You can’t perform that action at this time.