-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear.ps1
More file actions
54 lines (43 loc) · 1.98 KB
/
clear.ps1
File metadata and controls
54 lines (43 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env pwsh
Write-Host "=== Clear Workspace Artifacts ===" -ForegroundColor Cyan
# Remove build artifacts
Write-Host "\nRemoving old build artifacts..." -ForegroundColor Yellow
if (Test-Path "Builds") {
Remove-Item -Recurse -Force "Builds"
Write-Host "Removed Builds folder" -ForegroundColor Green
}
# Remove Library folder (forces complete reimport)
Write-Host "\nPruning Library folder (preserving PackageCache) ..." -ForegroundColor Yellow
if (Test-Path "Library") {
$pkgCache = Join-Path (Get-Item -Path ".").FullName 'Library\PackageCache'
$backup = Join-Path (Get-Item -Path ".").FullName '.packagecache_backup'
if (Test-Path $pkgCache) {
Write-Host "Backing up Library\\PackageCache to $backup" -ForegroundColor Yellow
if (Test-Path $backup) { Remove-Item -Recurse -Force $backup }
Move-Item -Force $pkgCache $backup
}
Remove-Item -Recurse -Force "Library"
if (Test-Path $backup) {
Write-Host "Restoring PackageCache into Library..." -ForegroundColor Yellow
New-Item -ItemType Directory -Force -Path "Library" | Out-Null
Move-Item -Force $backup (Join-Path (Get-Item -Path ".").FullName 'Library\PackageCache')
# Move-Item removes the source path. Only clean up if something unexpected remains.
if (Test-Path $backup) {
Remove-Item -Recurse -Force $backup
}
}
Write-Host "Pruned Library folder (preserved PackageCache)" -ForegroundColor Green
}
# Remove Temp folder
Write-Host "\nRemoving Temp folder..." -ForegroundColor Yellow
if (Test-Path "Temp") {
Remove-Item -Recurse -Force "Temp"
Write-Host "Removed Temp folder" -ForegroundColor Green
}
# Remove obj folder
Write-Host "\nRemoving obj folder..." -ForegroundColor Yellow
if (Test-Path "obj") {
Remove-Item -Recurse -Force "obj"
Write-Host "Removed obj folder" -ForegroundColor Green
}
Write-Host "\n=== Clear completed ===" -ForegroundColor Green