Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into refctor/parse_ap…
Browse files Browse the repository at this point in the history
…p-n-get-manifest
  • Loading branch information
HUMORCE committed Sep 28, 2024
2 parents 984c662 + 3577f91 commit 882583e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **scoop-download|install|update:** Fallback to default downloader when aria2 fails ([#4292](https://github.com/ScoopInstaller/Scoop/issues/4292))
- **decompress**: `Expand-7zipArchive` only delete temp dir / `$extractDir` if it is empty ([#6092](https://github.com/ScoopInstaller/Scoop/issues/6092))
- **commands**: Handling broken aliases ([#6141](https://github.com/ScoopInstaller/Scoop/issues/6141))

### Code Refactoring

Expand Down
16 changes: 13 additions & 3 deletions lib/commands.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function command_files {
(Get-ChildItem "$PSScriptRoot\..\libexec") + (Get-ChildItem "$scoopdir\shims") |
Where-Object 'scoop-.*?\.ps1$' -Property Name -Match
Where-Object 'scoop-.*?\.ps1$' -Property Name -Match
}

function commands {
Expand Down Expand Up @@ -86,7 +86,9 @@ function rm_alias {
}

info "Removing alias '$name'..."
Remove-Item "$(shimdir $false)\scoop-$name.ps1"
if (Test-Path "$(shimdir $false)\scoop-$name.ps1") {
Remove-Item "$(shimdir $false)\scoop-$name.ps1"
}
$aliases.PSObject.Properties.Remove($name)
set_config ALIAS $aliases | Out-Null
}
Expand All @@ -98,11 +100,19 @@ function list_aliases {

$aliases = get_config ALIAS ([PSCustomObject]@{})
$alias_info = $aliases.PSObject.Properties.Name | Where-Object { $_ } | ForEach-Object {
# Mark the alias as <BROKEN>, if the alias script file does NOT exist.
if (!(Test-Path "$(shimdir $false)\scoop-$_.ps1")) {
[PSCustomObject]@{
Name = $_
Command = '<BROKEN>'
}
return
}
$content = Get-Content (command_path $_)
[PSCustomObject]@{
Name = $_
Summary = (summary $content).Trim()
Command = ($content | Select-Object -Skip 1).Trim()
Summary = (summary $content).Trim()
}
}
if (!$alias_info) {
Expand Down

0 comments on commit 882583e

Please sign in to comment.