Skip to content

Commit aec3d67

Browse files
committed
fix: propagate error instead of panicking on scripts dir resolution failure
1 parent 45aacdd commit aec3d67

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

crates/vite_global_cli/src/js_executor.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,14 @@ impl JsExecutor {
210210
args: &[String],
211211
) -> Result<ExitStatus, Error> {
212212
// Try to resolve vite-plus from the project directory using oxc_resolver
213-
let entry_point = Self::resolve_local_vite_plus(project_path).unwrap_or_else(|| {
214-
// Fall back to the global installation's bin.js
215-
let scripts_dir = self.get_scripts_dir().expect("scripts dir not found");
216-
scripts_dir.join("bin.js")
217-
});
213+
let entry_point = match Self::resolve_local_vite_plus(project_path) {
214+
Some(path) => path,
215+
None => {
216+
// Fall back to the global installation's bin.js
217+
let scripts_dir = self.get_scripts_dir()?;
218+
scripts_dir.join("bin.js")
219+
}
220+
};
218221

219222
tracing::debug!("Delegating to CLI via JS entry point: {:?} {:?}", entry_point, args);
220223

0 commit comments

Comments
 (0)