fix: npm view should respect configured registry when checking version

This commit is contained in:
i
2026-06-02 00:37:44 +08:00
parent 512c03dfab
commit 38ce541528
+2 -1
View File
@@ -227,7 +227,8 @@ function Detect-Installed {
function Get-RemoteNpmVersion {
if (-not (Get-Command "npm" -ErrorAction SilentlyContinue)) { return $null }
try {
$ver = (& npm view $script:NPM_PACKAGE version 2>$null).Trim()
$regArg = if ($script:NPM_REGISTRY -and $script:NPM_REGISTRY -ne "https://registry.npmjs.org") { "--registry=$($script:NPM_REGISTRY)" } else { "" }
$ver = (& npm view $script:NPM_PACKAGE version $regArg 2>$null).Trim()
if ($ver) { return $ver }
} catch {}
return $null