Skip to content

Commit bfaa80f

Browse files
committed
fix(installer): merge redundant params and preserve version on empty input
- Merge target_version and resolved_version into single version param in install_new_version (they always had the same value at call site) - Empty input on version prompt now keeps the current value instead of resetting to the default tag
1 parent c7f59c6 commit bfaa80f

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

crates/vite_installer/src/main.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ async fn do_install(
226226
&version_dir,
227227
install_dir,
228228
&target_version,
229-
&resolved.version,
230229
current_version.is_some(),
231230
)
232231
.await;
@@ -329,8 +328,7 @@ async fn install_new_version(
329328
platform_data: &[u8],
330329
version_dir: &AbsolutePathBuf,
331330
install_dir: &AbsolutePathBuf,
332-
target_version: &str,
333-
resolved_version: &str,
331+
version: &str,
334332
has_previous: bool,
335333
) -> Result<(), Box<dyn std::error::Error>> {
336334
if !opts.quiet {
@@ -343,25 +341,20 @@ async fn install_new_version(
343341
return Err("Binary not found after extraction. The download may be corrupted.".into());
344342
}
345343

346-
install::generate_wrapper_package_json(version_dir, target_version).await?;
344+
install::generate_wrapper_package_json(version_dir, version).await?;
347345

348346
if !opts.quiet {
349347
print_info("installing dependencies (this may take a moment)...");
350348
}
351-
install::install_production_deps(
352-
version_dir,
353-
opts.registry.as_deref(),
354-
opts.yes,
355-
resolved_version,
356-
)
357-
.await?;
349+
install::install_production_deps(version_dir, opts.registry.as_deref(), opts.yes, version)
350+
.await?;
358351

359352
let previous_version =
360353
if has_previous { install::save_previous_version(install_dir).await? } else { None };
361-
install::swap_current_link(install_dir, target_version).await?;
354+
install::swap_current_link(install_dir, version).await?;
362355

363356
// Cleanup with both new and previous versions protected (matches vp upgrade)
364-
let mut protected = vec![target_version];
357+
let mut protected = vec![version];
365358
if let Some(ref prev) = previous_version {
366359
protected.push(prev.as_str());
367360
}
@@ -559,8 +552,10 @@ fn show_customize_menu(opts: &mut cli::Options) {
559552
match choice.as_str() {
560553
"" => return,
561554
"1" => {
562-
let v = read_input(" Version (e.g. 0.3.0 or latest): ");
563-
if v.is_empty() || v == opts.tag {
555+
let v = read_input(" Version (e.g. 0.3.0 or latest, Enter to keep): ");
556+
if v.is_empty() {
557+
// Keep current value
558+
} else if v == opts.tag {
564559
opts.version = None;
565560
} else {
566561
opts.version = Some(v);

0 commit comments

Comments
 (0)