From c0d7255256c4869c2d69195ccc14e45f6d72b72b Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 4 Feb 2021 15:14:09 +0300 Subject: [PATCH] Rework cleanup script --- __tests__/clear-toolcache.ps1 | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/__tests__/clear-toolcache.ps1 b/__tests__/clear-toolcache.ps1 index 1fed65d..44ba345 100644 --- a/__tests__/clear-toolcache.ps1 +++ b/__tests__/clear-toolcache.ps1 @@ -1,21 +1,11 @@ -$os = $args[0] - -$linuxDotnetPaths = @("/usr/share/dotnet") -$macOSDotnetPaths = @("$env:HOME/.dotnet") -$windowsDotnetPaths = @("$env:ProgramFiles\dotnet/*", - "$env:LocalAppData\Microsoft\dotnet/*") - -$pathsToClear = @() - -if ($os -eq "Linux") { - $pathsToClear = $linuxDotnetPaths -} elseif ($os -eq "macOS") { - $pathsToClear = $macOSDotnetPaths -} elseif ($os -eq "Windows") { - $pathsToClear = $windowsDotnetPaths +$dotnetPaths = @{ + Linux = @("/usr/share/dotnet") + macOS = @("$env:HOME/.dotnet") + Windows = @("$env:ProgramFiles\dotnet/*", + "$env:LocalAppData\Microsoft\dotnet/*") } -foreach ($path in $pathsToClear) { +foreach ($path in $dotnetPaths[$args[0]]) { if (Test-Path $path) { Write-Host "Clear $path path" Remove-Item $path -Recurse -Force