Skip to content

Commit

Permalink
fix asinine powershell issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Jan 25, 2025
1 parent 10a3678 commit 1a1df60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ci/pack_nuget/zip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ param(
$ArchiveFile = $ArchiveFile -replace '/', '\'
$OriginalArchiveFile = $ArchiveFile

# Get just the filename from OriginalArchiveFile using the proper api
$OriginalArchiveFileName = (Get-Item -Path $ArchiveFile).Name

# Reasoning: Ensure the archive file has a .zip extension to comply with Compress-Archive requirements.
# Goal: Append .zip if the provided archive filename does not already end with .zip
if (-not $ArchiveFile.EndsWith('.zip', [System.StringComparison]::InvariantCultureIgnoreCase)) {
Expand All @@ -36,6 +39,7 @@ if (-not $ArchiveFile.EndsWith('.zip', [System.StringComparison]::InvariantCultu
# Reasoning: Convert forward slashes to backslashes in all paths for Windows compatibility.
# Goal: Ensure all provided paths use the correct directory separator.
$Paths = $Paths | ForEach-Object { $_ -replace '/', '\' }
Write-Host "Compressing the following files: $Paths"

# Reasoning: Determine if the archive already exists to decide between creating a new archive or updating an existing one.
# Goal: Utilize the -Update flag when appropriate to add files to an existing archive.
Expand All @@ -52,8 +56,8 @@ try {
# Reasoning: Rename the archive back to the original filename if it was modified.
# Goal: Maintain the user's intended archive filename without the .zip extension in the final output.
if ($ArchiveFile -ne $OriginalArchiveFile) {
Write-Host "Renaming '$ArchiveFile' back to '$OriginalArchiveFile'..."
Rename-Item -Path $ArchiveFile -NewName $OriginalArchiveFile -ErrorAction Stop
Write-Host "Renaming '$ArchiveFile' back to '$OriginalArchiveFileName'..."
Rename-Item -Path $ArchiveFile -NewName $OriginalArchiveFileName -ErrorAction Stop
}

# Reasoning: Indicate successful completion of the compression and renaming process.
Expand Down

0 comments on commit 1a1df60

Please sign in to comment.