aboutsummaryrefslogtreecommitdiff
path: root/run.ps1
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-02 16:42:03 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-02 16:42:03 +0800
commit685f461e181a22b6112ab2ee3ed9caba46998c4b (patch)
tree3e923b13b199bebb1935accf3f85abcc95ae3a36 /run.ps1
parent9ae850143321a2e9b8b8d0c998df411249ae57b3 (diff)
fix(run): force $sorted to array to avoid char indexing on single tool
When only one tool exists, the sorted pipeline returns a single string instead of an array. Indexing it (e.g., $sorted[0]) then returns a character rather than the full tool name, causing errors like "Method invocation failed because [System.Char] does not contain a method named 'ToLower'". Wrapping the pipeline in @() ensures $sorted is always an array, fixing both the list display and number-based selection.
Diffstat (limited to 'run.ps1')
-rw-r--r--run.ps14
1 files changed, 2 insertions, 2 deletions
diff --git a/run.ps1 b/run.ps1
index 3a7dc09..af8effe 100644
--- a/run.ps1
+++ b/run.ps1
@@ -73,7 +73,7 @@ if (Test-Path ".run/src/bin/*.zig") {
}
if ($args.Count -eq 0) {
- $sorted = $tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_}
+ $sorted = @($tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_})
$total = $sorted.Count
$num_w = $total.ToString().Length
@@ -120,7 +120,7 @@ if ($args.Count -eq 0) {
$target_name = $args[0]
if ($target_name -match '^\d+$') {
- $sorted = $tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_}
+ $sorted = @($tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_})
$idx = [int]$target_name - 1
if ($idx -ge 0 -and $idx -lt $sorted.Count) {
$target_name = $sorted[$idx]