From b1d56441956ab2fd711eabe65d5a365d2cd195bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8C=C3=A1bera?= Date: Fri, 2 Jul 2021 22:50:08 +0200 Subject: [PATCH] feat: Report failed installations/updates at the end of execution (#174) --- CHANGELOG.md | 1 + libexec/scoop-install.ps1 | 6 +++++- libexec/scoop-update.ps1 | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d58cfdc6c..d23b3d5f93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [0.6.5](https://github.com/Ash258/Scoop-Core/milestone/5) +- **scoop-install**, **scoop-update**: Report failed installations/updates at the end of execution - **Schema**: - Initial support for `arm64` architecture - Allow `$schema` property diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 91862551d6..ac65b35cb4 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -142,6 +142,7 @@ $skip | Where-Object { $explicit_apps -contains $_ } | ForEach-Object { $suggested = @{ } $failedDependencies = @() +$failedApplications = @() foreach ($app in $apps) { $bucket = $cleanApp = $null @@ -175,7 +176,7 @@ foreach ($app in $apps) { ++$problems # Register failed dependencies - if ($explicit_apps -notcontains $app) { $failedDependencies += $app } + if ($explicit_apps -notcontains $app) { $failedDependencies += $app } else { $failedApplications += $app } $title, $body = $_.Exception.Message -split '\|-' if (!$body) { $body = $title } @@ -189,6 +190,9 @@ foreach ($app in $apps) { show_suggestions $suggested +if ($failedApplications) { Write-UserMessage -Message "These applications failed to install: $($failedApplications -join ', ')" -Err } +if ($failedDependencies) { Write-UserMessage -Message "These dependencies failed to install: $($failedDependencies -join ', ')" -Err } + if ($problems -gt 0) { $exitCode = 10 + $problems } exit $exitCode diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 254d9799a4..7170d58704 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -44,6 +44,7 @@ if (!$Applications) { if (is_scoop_outdated) { Update-Scoop } $outdatedApplications = @() + $failedApplications = @() $applicationsParam = $Applications # Original users request if ($applicationsParam -eq '*') { @@ -87,6 +88,8 @@ if (!$Applications) { } catch { ++$Problems + $failedApplications += $out[0] + $title, $body = $_.Exception.Message -split '\|-' if (!$body) { $body = $title } Write-UserMessage -Message $body -Err @@ -98,6 +101,8 @@ if (!$Applications) { } } +if ($failedApplications) { Write-UserMessage -Message "These applications failed to update: $($failedApplications -join ', ')" -Err } + if ($Problems -gt 0) { $ExitCode = 10 + $Problems } exit $ExitCode