mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-30 06:07:56 +00:00
fix(commands): Handling broken aliases (#6141)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user