Skip to content

Commit 4808cfe

Browse files
committed
fix(env): default the pin overwrite prompt to yes
The user runs 'vp env pin <version>' explicitly, so pressing Enter at the overwrite confirmation should accept. Change the prompt to (Y/n) and cancel only on an explicit no instead of requiring an explicit y.
1 parent 12ad06a commit 4808cfe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • crates/vite_global_cli/src/commands/env

crates/vite_global_cli/src/commands/env/pin.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,18 @@ fn confirm_overwrite_pin(
226226
return Ok(true);
227227
}
228228

229-
// Prompt for confirmation
229+
// Prompt for confirmation, defaulting to yes (the user explicitly asked to
230+
// pin a new version, so only an explicit "no" cancels)
230231
print!("{source_label} {existing_version}");
231232
println!();
232-
print!("Overwrite with {resolved_version}? (y/n): ");
233+
print!("Overwrite with {resolved_version}? (Y/n): ");
233234
std::io::stdout().flush()?;
234235

235236
let mut input = String::new();
236237
std::io::stdin().read_line(&mut input)?;
237238

238-
if !input.trim().eq_ignore_ascii_case("y") {
239+
let answer = input.trim();
240+
if answer.eq_ignore_ascii_case("n") || answer.eq_ignore_ascii_case("no") {
239241
println!("Cancelled.");
240242
return Ok(false);
241243
}

0 commit comments

Comments
 (0)