Remove the .aikido directory when uninstalling

This commit is contained in:
Sander Declerck 2026-03-19 09:13:45 +01:00
parent 6c6ce796d9
commit 9494b5aae8
No known key found for this signature in database
2 changed files with 36 additions and 25 deletions

View file

@ -4,7 +4,9 @@
# Use HOME on Unix, USERPROFILE on Windows (PowerShell Core is cross-platform)
$HomeDir = if ($env:HOME) { $env:HOME } else { $env:USERPROFILE }
$InstallDir = Join-Path $HomeDir ".safe-chain/bin"
$DotSafeChain = Join-Path $HomeDir ".safe-chain"
$DotAikido = Join-Path $HomeDir ".aikido"
$InstallDir = Join-Path $DotSafeChain "bin"
# Helper functions
function Write-Info {
@ -123,34 +125,34 @@ function Uninstall-SafeChain {
Remove-NpmInstallation
Remove-VoltaInstallation
# Remove installation directory
if (Test-Path $InstallDir) {
Write-Info "Removing installation directory: $InstallDir"
# Remove .safe-chain directory
if (Test-Path $DotSafeChain) {
Write-Info "Removing installation directory: $DotSafeChain"
try {
Remove-Item -Path $InstallDir -Recurse -Force
Remove-Item -Path $DotSafeChain -Recurse -Force
Write-Info "Successfully removed installation directory"
}
catch {
Write-Error-Custom "Failed to remove $InstallDir : $_"
Write-Error-Custom "Failed to remove $DotSafeChain : $_"
}
}
else {
Write-Info "Installation directory $InstallDir does not exist. Nothing to remove."
Write-Info "Installation directory $DotSafeChain does not exist. Nothing to remove."
}
# Also try to remove the parent .safe-chain directory if it's empty
$parentDir = Split-Path $InstallDir -Parent
if (Test-Path $parentDir) {
$items = Get-ChildItem -Path $parentDir -Force
if ($items.Count -eq 0) {
Write-Info "Removing empty parent directory: $parentDir"
# Remove .aikido directory
if (Test-Path $DotAikido) {
Write-Info "Removing installation directory: $DotAikido"
try {
Remove-Item -Path $parentDir -Force
Remove-Item -Path $DotAikido -Recurse -Force
Write-Info "Successfully removed installation directory"
}
catch {
Write-Warn "Could not remove empty parent directory: $_"
Write-Error-Custom "Failed to remove $DotAikido : $_"
}
}
else {
Write-Info "Installation directory $DotAikido does not exist. Nothing to remove."
}
Write-Info "safe-chain has been uninstalled successfully!"

View file

@ -7,7 +7,8 @@
set -e # Exit on error
# Configuration
INSTALL_DIR="${HOME}/.safe-chain/bin"
DOT_SAFE_CHAIN="${HOME}/.safe-chain"
DOT_AIKIDO="${HOME}/.aikido"
# Colors for output
RED='\033[0;31m'
@ -139,7 +140,7 @@ remove_nvm_installation() {
# Main uninstallation
main() {
SAFE_CHAIN_LOCATION="$INSTALL_DIR/safe-chain"
SAFE_CHAIN_LOCATION="$DOT_SAFE_CHAIN/bin/safe-chain"
if [ -x "$SAFE_CHAIN_LOCATION" ]; then
info "Running safe-chain teardown..."
@ -157,11 +158,19 @@ main() {
remove_nvm_installation
# Remove install dir recursively if it exists
if [ -d "$INSTALL_DIR" ]; then
info "Removing installation directory $INSTALL_DIR"
rm -rf "$INSTALL_DIR" || error "Failed to remove $INSTALL_DIR"
if [ -d "$DOT_SAFE_CHAIN" ]; then
info "Removing installation directory $DOT_SAFE_CHAIN"
rm -rf "$DOT_SAFE_CHAIN" || error "Failed to remove $DOT_SAFE_CHAIN"
else
info "Installation directory $INSTALL_DIR does not exist. Nothing to remove."
info "Installation directory $DOT_SAFE_CHAIN does not exist. Nothing to remove."
fi
# Remove install dir recursively if it exists
if [ -d "$DOT_AIKIDO" ]; then
info "Removing installation directory $DOT_AIKIDO"
rm -rf "$DOT_AIKIDO" || error "Failed to remove $DOT_AIKIDO"
else
info "Installation directory $DOT_AIKIDO does not exist. Nothing to remove."
fi
}