-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.ps1
executable file
·54 lines (49 loc) · 2.47 KB
/
clean.ps1
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
# Get component metadata and set necessary variables
$component = Get-Content -Path "$PSScriptRoot/component.json" | ConvertFrom-Json
$testImage = "$($component.registry)/$($component.name):$($component.version)-$($component.build)-test"
$docsImage="$($component.registry)/$($component.name):$($component.version)-$($component.build)-docs"
# Remove docker images
docker rmi $testImage --force
docker rmi $docsImage --force
docker rmi -f $(docker images -f "dangling=true" -q) # remove build container if build fails
docker image prune --force
# Remove existed containers
$exitedContainers = docker ps -a | Select-String -Pattern "Exit"
foreach($c in $exitedContainers) { docker rm $c.ToString().Split(" ")[0] }
# Remove unused volumes
docker volume rm -f $(docker volume ls -f "dangling=true")
# Remove cash and temp files
if (Test-Path -Path "$PSScriptRoot/cache") {
Remove-Item -Path "$PSScriptRoot/cache" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/dist") {
Remove-Item -Path "$PSScriptRoot/dist" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/$($component.name.replace('-', '_')).egg-info") {
Remove-Item -Path "$PSScriptRoot/$($component.name.replace('-', '_')).egg-info" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/$($component.name.replace('-', '_')).egg-info") {
Remove-Item -Path "$PSScriptRoot/$($component.name.replace('-', '_')).egg-info" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/*.pyc") {
Remove-Item -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/*.pyc" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/**/*.pyc") {
Remove-Item -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/**/*.pyc" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/__pycache__") {
Remove-Item -Path "$PSScriptRoot/$($component.name.replace('-', '_'))/__pycache__" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/test/__pycache__") {
Remove-Item -Path "$PSScriptRoot/test/__pycache__" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/test/**/__pycache__") {
Remove-Item -Path "$PSScriptRoot/test/**/__pycache__" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/test/.pytest_cache") {
Remove-Item -Path "$PSScriptRoot/test/.pytest_cache" -Recurse -Force
}
if (Test-Path -Path "$PSScriptRoot/test/**/.pytest_cache") {
Remove-Item -Path "$PSScriptRoot/test/**/.pytest_cache" -Recurse -Force
}