Skip to content

Commit 85328fe

Browse files
committed
fix: use custom registry if exist
1 parent a9c7034 commit 85328fe

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

crates/vite_setup/src/install.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub async fn install_production_deps(
284284
format!("pnpm entry not found at {}", pnpm_entry.as_path().display()).into(),
285285
));
286286
}
287-
let output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args).await?;
287+
let output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args, registry).await?;
288288

289289
if !output.status.success() {
290290
let log_path = write_upgrade_log(version_dir, &output.stdout, &output.stderr).await;
@@ -316,7 +316,7 @@ pub async fn install_production_deps(
316316
// Only create the local override after explicit consent. This preserves
317317
// minimumReleaseAge protection for the default and non-interactive paths.
318318
write_release_age_overrides(version_dir).await?;
319-
let retry_output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args).await?;
319+
let retry_output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args, registry).await?;
320320
if !retry_output.status.success() {
321321
let retry_log_path =
322322
write_upgrade_log(version_dir, &retry_output.stdout, &retry_output.stderr).await;
@@ -339,6 +339,7 @@ async fn run_pnpm_install(
339339
node_runtime: &vite_js_runtime::JsRuntime,
340340
pnpm_entry: &AbsolutePath,
341341
args: &[&str],
342+
registry: Option<&str>,
342343
) -> Result<Output, Error> {
343344
let node_bin = node_runtime.get_bin_prefix();
344345
let pnpm_bin = pnpm_entry.parent().ok_or_else(|| {
@@ -350,15 +351,18 @@ async fn run_pnpm_install(
350351
let path = env::join_paths(path_entries)
351352
.map_err(|error| Error::Setup(format!("Failed to build PATH for pnpm: {error}").into()))?;
352353

353-
let output = tokio::process::Command::new(node_runtime.get_binary_path().as_path())
354-
.arg(pnpm_entry.as_path())
354+
let mut cmd = tokio::process::Command::new(node_runtime.get_binary_path().as_path());
355+
cmd.arg(pnpm_entry.as_path())
355356
.args(args)
356357
.current_dir(version_dir)
357358
.env("CI", "true")
358-
.env("PATH", path)
359-
.output()
360-
.await?;
359+
.env("PATH", path);
360+
361+
if let Some(registry_url) = registry {
362+
cmd.env("npm_config_registry", registry_url);
363+
}
361364

365+
let output = cmd.output().await?;
362366
Ok(output)
363367
}
364368

0 commit comments

Comments
 (0)