mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge pull request #337 from AikidoSec/remove-dotaikido-in-uninstall
Remove the .aikido directory when uninstalling
This commit is contained in:
commit
5864b09bde
7 changed files with 129 additions and 76 deletions
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
# 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"
|
||||
$InstallDir = Join-Path $DotSafeChain "bin"
|
||||
|
||||
# Helper functions
|
||||
function Write-Info {
|
||||
|
|
@ -123,34 +124,19 @@ 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."
|
||||
}
|
||||
|
||||
# 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"
|
||||
try {
|
||||
Remove-Item -Path $parentDir -Force
|
||||
}
|
||||
catch {
|
||||
Write-Warn "Could not remove empty parent directory: $_"
|
||||
}
|
||||
}
|
||||
Write-Info "Installation directory $DotSafeChain does not exist. Nothing to remove."
|
||||
}
|
||||
|
||||
Write-Info "safe-chain has been uninstalled successfully!"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
set -e # Exit on error
|
||||
|
||||
# Configuration
|
||||
INSTALL_DIR="${HOME}/.safe-chain/bin"
|
||||
DOT_SAFE_CHAIN="${HOME}/.safe-chain"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
|
|
@ -139,7 +139,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 +157,11 @@ 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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue