From a6ab1f1eb746b04054a2c4dcece39adcab51931a Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 30 Jan 2026 19:55:29 -0700 Subject: [PATCH] Fail windows bundle when cargo about fails (#48056) Release Notes: - N/A --- script/bundle-windows.ps1 | 3 --- script/generate-licenses.ps1 | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/script/bundle-windows.ps1 b/script/bundle-windows.ps1 index f4b83785f99773458a8a5ea970a57cf694d3e7d9..53527e1b8f9b669c8ab17d8232ccffd917638419 100644 --- a/script/bundle-windows.ps1 +++ b/script/bundle-windows.ps1 @@ -96,10 +96,7 @@ function PrepareForBundle { } function GenerateLicenses { - $oldErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = 'Continue' . $PSScriptRoot/generate-licenses.ps1 - $ErrorActionPreference = $oldErrorActionPreference } function BuildZedAndItsFriends { diff --git a/script/generate-licenses.ps1 b/script/generate-licenses.ps1 index 80cd249a46582e51e86870d347f922854a76a069..ae1c470eaefdc14dfba5cd3345cac97521b1b982 100644 --- a/script/generate-licenses.ps1 +++ b/script/generate-licenses.ps1 @@ -1,3 +1,6 @@ +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + $CARGO_ABOUT_VERSION="0.8.2" $outputFile=$args[0] ? $args[0] : "$(Get-Location)/assets/licenses.md" $templateFile="script/licenses/template.md.hbs" @@ -12,12 +15,21 @@ New-Item -Path "$outputFile" -ItemType File -Value "" -Force "\n# ###### CODE LICENSES ######\n" ) | Add-Content -Path $outputFile -$versionOutput = cargo about --version -if (-not ($versionOutput -match "cargo-about $CARGO_ABOUT_VERSION")) { +$needsInstall = $false +try { + $versionOutput = cargo about --version + if (-not ($versionOutput -match "cargo-about $CARGO_ABOUT_VERSION")) { + $needsInstall = $true + } else { + Write-Host "cargo-about@$CARGO_ABOUT_VERSION is already installed" + } +} catch { + $needsInstall = $true +} + +if ($needsInstall) { Write-Host "Installing cargo-about@$CARGO_ABOUT_VERSION..." cargo install "cargo-about@$CARGO_ABOUT_VERSION" -} else { - Write-Host "cargo-about@$CARGO_ABOUT_VERSION" is already installed } Write-Host "Generating cargo licenses"