Skip to content

Commit

Permalink
feat: Report failed installations/updates at the end of execution (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Jul 2, 2021
1 parent 5084b17 commit b1d5644
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ $skip | Where-Object { $explicit_apps -contains $_ } | ForEach-Object {

$suggested = @{ }
$failedDependencies = @()
$failedApplications = @()

foreach ($app in $apps) {
$bucket = $cleanApp = $null
Expand Down Expand Up @@ -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 }
Expand All @@ -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
5 changes: 5 additions & 0 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ if (!$Applications) {
if (is_scoop_outdated) { Update-Scoop }

$outdatedApplications = @()
$failedApplications = @()
$applicationsParam = $Applications # Original users request

if ($applicationsParam -eq '*') {
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit b1d5644

Please sign in to comment.