Skip to content

Commit 358cc57

Browse files
authored
Refactor npm installation command execution
1 parent be532e9 commit 358cc57

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

deepstudio/private-install.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,27 @@ function DelCfg([string]$k) {
8585

8686
# IMPORTANT: Do NOT name parameters as $args (PowerShell automatic variable).
8787
function Run-NpmInstall([string[]]$npmArgs) {
88+
$cmdLine = "npm " + ($npmArgs -join " ")
89+
8890
if ($DryRun) {
89-
Info ("DRYRUN: npm " + ($npmArgs -join " "))
91+
Info ("DRYRUN: " + $cmdLine)
9092
return
9193
}
9294

9395
if (-not $EnableLog) {
94-
& npm @npmArgs
96+
& cmd.exe /d /s /c $cmdLine
9597
if ($LASTEXITCODE -ne 0) {
9698
throw "npm failed with exit code $LASTEXITCODE. (Tip: set DEEPSTUDIO_LOG=1 to capture full logs.)"
9799
}
98100
return
99101
}
100102

101-
# Logging enabled: use the resolved npm path (e.g., npm.cmd) for compatibility
102-
$npmPath = Get-NpmPath
103103
Info "Logging enabled. Log file: $LogPath"
104-
Info ("Resolved npm path: " + $npmPath)
104+
Info ("Command via cmd.exe: " + $cmdLine)
105105

106106
$psi = New-Object System.Diagnostics.ProcessStartInfo
107-
$psi.FileName = $npmPath
108-
$psi.Arguments = ($npmArgs -join " ")
107+
$psi.FileName = "cmd.exe"
108+
$psi.Arguments = "/d /s /c " + $cmdLine
109109
$psi.RedirectStandardOutput = $true
110110
$psi.RedirectStandardError = $true
111111
$psi.UseShellExecute = $false
@@ -128,8 +128,7 @@ function Run-NpmInstall([string[]]$npmArgs) {
128128
"Package: $PackageName@latest"
129129
"VerboseInstall: $VerboseInstall"
130130
"Registry: $registry/"
131-
"ResolvedNpm: $npmPath"
132-
"Command: npm " + ($npmArgs -join " ")
131+
"Command: $cmdLine"
133132
""
134133
"---- STDOUT ----"
135134
$stdout
@@ -147,6 +146,7 @@ function Run-NpmInstall([string[]]$npmArgs) {
147146
}
148147
}
149148

149+
150150
# ---------------------------
151151
# Start
152152
# ---------------------------

0 commit comments

Comments
 (0)