Skip to content

Commit b8d17fa

Browse files
authored
Update private-install.ps1
1 parent 43fa74d commit b8d17fa

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

deepstudio/private-install.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ function DelCfg([string]$k) {
7979
} catch {}
8080
}
8181

82-
function Run-NpmInstall([string[]]$args) {
82+
# IMPORTANT: Do NOT name parameters as $args (PowerShell automatic variable).
83+
function Run-NpmInstall([string[]]$npmArgs) {
8384
if ($DryRun) {
84-
Info ("DRYRUN: npm " + ($args -join " "))
85+
Info ("DRYRUN: npm " + ($npmArgs -join " "))
8586
return
8687
}
8788

8889
if (-not $EnableLog) {
89-
& npm @args
90+
& npm @npmArgs
9091
if ($LASTEXITCODE -ne 0) {
9192
throw "npm failed with exit code $LASTEXITCODE. (Tip: set DEEPSTUDIO_LOG=1 to capture full logs.)"
9293
}
@@ -98,7 +99,7 @@ function Run-NpmInstall([string[]]$args) {
9899

99100
$psi = New-Object System.Diagnostics.ProcessStartInfo
100101
$psi.FileName = "npm"
101-
$psi.Arguments = ($args -join " ")
102+
$psi.Arguments = ($npmArgs -join " ")
102103
$psi.RedirectStandardOutput = $true
103104
$psi.RedirectStandardError = $true
104105
$psi.UseShellExecute = $false
@@ -125,7 +126,7 @@ function Run-NpmInstall([string[]]$args) {
125126
"Package: $PackageName@latest"
126127
"VerboseInstall: $VerboseInstall"
127128
"Registry: $registry/"
128-
"Command: npm " + ($args -join " ")
129+
"Command: npm " + ($npmArgs -join " ")
129130
""
130131
"---- STDOUT ----"
131132
$stdout
@@ -202,6 +203,7 @@ try {
202203
SetCfg "${authPrefix}:username" "ms"
203204
SetCfg "${authPrefix}:_password" $patB64
204205
SetCfg "${authPrefix}:email" "npm@example.com"
206+
SetCfg "always-auth" "true"
205207

206208
Info ""
207209
Info ("Command: npm " + ($npmInstallArgs -join " "))
@@ -226,7 +228,6 @@ catch {
226228
Fail "❌ Installation failed."
227229
Fail ("Error: " + $_.Exception.Message)
228230

229-
# Helpful hints for common 401/403 issues
230231
Warn ""
231232
Warn "Common causes for 401/403:"
232233
Warn " - PAT missing Packaging:Read scope"
@@ -260,6 +261,7 @@ finally {
260261
DelCfg "${authPrefix}:username"
261262
DelCfg "${authPrefix}:_password"
262263
DelCfg "${authPrefix}:email"
264+
DelCfg "always-auth"
263265

264266
if ($VerboseInstall) {
265267
Remove-Item Env:\NPM_CONFIG_LOGLEVEL -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)