2024-10-21 06:50:02 +00:00
|
|
|
$envFilePath = ".\.env"
|
2024-10-21 06:36:06 +00:00
|
|
|
if (Test-Path $envFilePath) {
|
|
|
|
Get-Content $envFilePath | ForEach-Object {
|
|
|
|
if ($_ -match "^(.*?)=(.*)$") {
|
|
|
|
$name = $matches[1]
|
|
|
|
$value = $matches[2]
|
|
|
|
[System.Environment]::SetEnvironmentVariable($name, $value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Write-Output ".env file not found"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2024-10-21 06:50:02 +00:00
|
|
|
$maxAge = -([System.Environment]::GetEnvironmentVariable("MAX_AGE"))
|
2024-10-21 06:36:06 +00:00
|
|
|
$outputPath = [System.Environment]::GetEnvironmentVariable("OUTPUT_PATH")
|
|
|
|
|
|
|
|
# Get files older than MAX_AGE hours and delete them
|
|
|
|
Get-ChildItem -Path $outputPath -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddHours($maxAge) } | Remove-Item
|