1param (
2 [Parameter(Mandatory = $true)]
3 [int]$MAX_SIZE_IN_GB
4)
5
6$ErrorActionPreference = "Stop"
7$PSNativeCommandUseErrorActionPreference = $true
8$ProgressPreference = "SilentlyContinue"
9
10if (-Not (Test-Path -Path "target")) {
11 Write-Host "target directory does not exist yet"
12 exit 0
13}
14
15$current_size_gb = (Get-ChildItem -Recurse -Force -File -Path "target" | Measure-Object -Property Length -Sum).Sum / 1GB
16
17Write-Host "target directory size: ${current_size_gb}GB. max size: ${MAX_SIZE_IN_GB}GB"
18
19if ($current_size_gb -gt $MAX_SIZE_IN_GB) {
20 Write-Host "Dev drive is almost full, increase the size first!"
21 exit 1
22}