From 25106bfc04c3061618d077121747d70d227628de Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Mon, 29 Jun 2026 00:23:00 +0800 Subject: [PATCH] fix(command): resolve fspy program before spawn --- crates/vite_command/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/vite_command/src/lib.rs b/crates/vite_command/src/lib.rs index 61f6f041a4..dc35f0c7c5 100644 --- a/crates/vite_command/src/lib.rs +++ b/crates/vite_command/src/lib.rs @@ -206,16 +206,19 @@ where S: AsRef, { let cwd = cwd.as_ref(); + let (program, prefix_args) = resolve_program(bin_name, envs, cwd)?; let args: Vec = args.into_iter().map(|s| s.as_ref().to_owned()).collect(); tracing::debug!( target: "vite_command::spawn", - bin_name, + program = %program.as_path().display(), + prefix_args = ?prefix_args, args = ?args, cwd = %cwd.as_path().display(), "spawn (fspy)", ); - let mut cmd = fspy::Command::new(bin_name); - cmd.args(&args) + let mut cmd = fspy::Command::new(program.as_path()); + cmd.args(&prefix_args) + .args(&args) // set system environment variables first .envs(std::env::vars_os()) // then set custom environment variables @@ -497,12 +500,9 @@ mod tests { run_command_with_fspy("npm-not-exists", &["--version"], &envs, &temp_dir_path) .await; assert!(result.is_err(), "Should not find binary path, but got: {:?}", result); - assert!( - result - .err() - .unwrap() - .to_string() - .contains("could not resolve the full path of program '\"npm-not-exists\"'") + assert_eq!( + result.unwrap_err().to_string(), + "Cannot find binary path for command 'npm-not-exists'" ); } }