Skip to content

Commit 934e829

Browse files
authored
Merge pull request #79 from codecrafters-io/andy/test-path
Make Test-Path more robust
2 parents c182258 + b371668 commit 934e829

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

install.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ try {
4040

4141
tar -xzf $TarGzPath -C $TempDir
4242

43-
if (-not (Test-Path $InstallDir)) {
43+
if (-not (Test-Path -LiteralPath $InstallDir)) {
4444
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
4545
}
4646

@@ -62,7 +62,11 @@ try {
6262
Write-Host ""
6363
} finally {
6464
# Cleanup
65-
if (Test-Path $TempDir) {
66-
Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue
65+
if (Test-Path -LiteralPath $TempDir) {
66+
try {
67+
Remove-Item -LiteralPath $TempDir -Recurse -Force -ErrorAction Stop
68+
} catch {
69+
Write-Host "Warning: couldn't clean up temporary folder: $TempDir" -ForegroundColor Yellow
70+
}
6771
}
6872
}

0 commit comments

Comments
 (0)