fix: show npm package path in confirmation prompt when source is npm

This commit is contained in:
i
2026-06-02 00:51:58 +08:00
parent 6d73f2cbf1
commit 43d29e4fee
2 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -1135,7 +1135,12 @@ function Run-QuickMode {
Write-Host "即将${action} HAPI CLI:" -ForegroundColor White
Write-Host " 版本: v$($script:REMOTE_VERSION)" -ForegroundColor Cyan
Write-Host " 来源: $srcLabel" -ForegroundColor Cyan
Write-Host " 目录: $($script:INSTALL_DIR)" -ForegroundColor Cyan
$installDirDisplay = if ($script:SELECTED_SOURCE -eq "npm" -and $script:INSTALLED_SOURCE -eq "npm") {
$npmRoot = & npm root -g 2>$null
if (-not $npmRoot) { $npmRoot = if ($IsWindows) { "$env:APPDATA\npm\node_modules" } else { "/usr/lib/node_modules" } }
Join-Path $npmRoot $NPM_PACKAGE
} else { $script:INSTALL_DIR }
Write-Host " 目录: $installDirDisplay" -ForegroundColor Cyan
Write-Host ""
$confirm = Read-Host "确认${action}? [Y/n]"
if ($confirm -match '^[Nn]') {
+9 -1
View File
@@ -1507,7 +1507,15 @@ run_quick_mode() {
echo -e "${BOLD}即将${action} HAPI CLI:${NC}"
echo -e " 版本: ${CYAN}v$REMOTE_VERSION${NC}"
echo -e " 来源: ${CYAN}$src_label${NC}"
echo -e " 目录: ${CYAN}$INSTALL_DIR${NC}"
local dir_display
if [[ "$SELECTED_SOURCE" == "npm" && "$INSTALLED_SOURCE" == "npm" ]]; then
local npm_root
npm_root=$(npm root -g 2>/dev/null || echo "/usr/lib/node_modules")
dir_display="$npm_root/$NPM_PACKAGE"
else
dir_display="$INSTALL_DIR"
fi
echo -e " 目录: ${CYAN}$dir_display${NC}"
echo ""
read -rp "确认${action}? [Y/n]: " confirm
if [[ "$confirm" =~ ^[Nn] ]]; then