59 lines
No EOL
2 KiB
PowerShell
59 lines
No EOL
2 KiB
PowerShell
param(
|
|
[switch]$modules,
|
|
[switch]$dist,
|
|
[switch]$all,
|
|
[switch]$fresh
|
|
)
|
|
|
|
function Remove-DirectoriesByName {
|
|
param([string]$Name, [string]$Description)
|
|
|
|
Write-Host "Removing $Description..." -ForegroundColor Blue
|
|
$directories = Get-ChildItem -Path . -Name $Name -Recurse -Directory -ErrorAction SilentlyContinue
|
|
|
|
if ($directories.Count -gt 0) {
|
|
Write-Host "Found $($directories.Count) $Description to remove" -ForegroundColor Gray
|
|
$directories | ForEach-Object {
|
|
Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue
|
|
Write-Host " Removed: $_" -ForegroundColor Gray
|
|
}
|
|
} else {
|
|
Write-Host "No $Description found" -ForegroundColor Gray
|
|
}
|
|
}
|
|
|
|
Write-Host "Starting cleanup..." -ForegroundColor Yellow
|
|
|
|
if ($all -or $fresh) {
|
|
Remove-DirectoriesByName "node_modules" "node_modules directories"
|
|
Remove-DirectoriesByName "dist" "dist directories"
|
|
|
|
Write-Host "Removing lock files..." -ForegroundColor Blue
|
|
Remove-Item -Path "bun.lockb" -Force -ErrorAction SilentlyContinue
|
|
Get-ChildItem -Path . -Name "bun.lockb" -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue
|
|
|
|
# Remove turbo clean since PowerShell already cleaned everything
|
|
Write-Host "Cleanup complete - no need for turbo clean" -ForegroundColor Blue
|
|
}
|
|
elseif ($modules) {
|
|
Remove-DirectoriesByName "node_modules" "node_modules directories"
|
|
|
|
Write-Host "Removing lock files..." -ForegroundColor Blue
|
|
Remove-Item -Path "bun.lockb" -Force -ErrorAction SilentlyContinue
|
|
Get-ChildItem -Path . -Name "bun.lockb" -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue
|
|
}
|
|
elseif ($dist) {
|
|
Remove-DirectoriesByName "dist" "dist directories"
|
|
}
|
|
else {
|
|
Write-Host "Running turbo clean..." -ForegroundColor Blue
|
|
# Only run turbo clean for the default case
|
|
turbo run clean
|
|
}
|
|
|
|
if ($fresh) {
|
|
Write-Host "Installing dependencies..." -ForegroundColor Green
|
|
bun install
|
|
}
|
|
|
|
Write-Host "Cleanup complete!" -ForegroundColor Green |