43 lines · 1.0 KB · executable
#!/usr/bin/env bash

brewLocation="charmbracelet/tap/crush"
npmLocation="@charmland/crush"

found=0
go_crush="$GOPATH/bin/crush"

if command -v brew >/dev/null 2>&1 && brew list "$brewLocation" >/dev/null 2>&1; then
    echo "Found Crush via Homebrew"
    found=1
fi

if command -v npm >/dev/null 2>&1 && npm list -g "$npmLocation" >/dev/null 2>&1; then
    echo "Found Crush via NPM"
    found=1
fi

if [[ -f "$go_crush" ]]; then
    echo "Found Crush Go binary at: $(which crush 2>/dev/null || echo "$go_crush")"
    found=1
fi

if [[ $found -eq 0 ]]; then
    echo "Crush is not installed"
    exit 1
fi

if command -v brew >/dev/null 2>&1 && brew list "$brewLocation" >/dev/null 2>&1; then
    echo "Uninstalling via Homebrew..."
    brew uninstall "$brewLocation"
fi

if command -v npm >/dev/null 2>&1 && npm list -g "$npmLocation" >/dev/null 2>&1; then
    echo "Uninstalling via NPM..."
    npm uninstall -g "$npmLocation"
fi

if [[ -f "$go_crush" ]]; then
    echo "Removing Go binary at $go_crush..."