Skip to content

Commit 84eb7d2

Browse files
committed
fix: use custom registry if exist
1 parent 342fd2f commit 84eb7d2

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

crates/vite_setup/src/install.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub async fn install_production_deps(
269269
args.push(registry_url);
270270
}
271271

272-
let output = run_vp_install(version_dir, &vp_binary, &args).await?;
272+
let output = run_vp_install(version_dir, &vp_binary, &args, registry).await?;
273273

274274
if !output.status.success() {
275275
let log_path = write_upgrade_log(version_dir, &output.stdout, &output.stderr).await;
@@ -301,7 +301,7 @@ pub async fn install_production_deps(
301301
// Only create the local override after explicit consent. This preserves
302302
// minimumReleaseAge protection for the default and non-interactive paths.
303303
write_release_age_overrides(version_dir).await?;
304-
let retry_output = run_vp_install(version_dir, &vp_binary, &args).await?;
304+
let retry_output = run_vp_install(version_dir, &vp_binary, &args, registry).await?;
305305
if !retry_output.status.success() {
306306
let retry_log_path =
307307
write_upgrade_log(version_dir, &retry_output.stdout, &retry_output.stderr).await;
@@ -323,14 +323,16 @@ async fn run_vp_install(
323323
version_dir: &AbsolutePath,
324324
vp_binary: &AbsolutePath,
325325
args: &[&str],
326+
registry: Option<&str>,
326327
) -> Result<Output, Error> {
327-
let output = tokio::process::Command::new(vp_binary.as_path())
328-
.args(args)
329-
.current_dir(version_dir)
330-
.env("CI", "true")
331-
.output()
332-
.await?;
328+
let mut cmd = tokio::process::Command::new(vp_binary.as_path());
329+
cmd.args(args).current_dir(version_dir).env("CI", "true");
330+
331+
if let Some(registry_url) = registry {
332+
cmd.env("npm_config_registry", registry_url);
333+
}
333334

335+
let output = cmd.output().await?;
334336
Ok(output)
335337
}
336338

0 commit comments

Comments
 (0)