Skip to content

Commit ead6747

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

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

.github/workflows/test-standalone-install.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
vp --help
7070
# test new command
7171
vp create vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
72-
cd hello && vp run build
72+
cd hello && vp run build && vp --version
7373
7474
- name: Set PATH
7575
shell: bash
@@ -108,7 +108,7 @@ jobs:
108108
run: |
109109
# --check queries npm registry and prints update status
110110
vp upgrade --check
111-
vp upgrade 0.0.0-b356849c.20260207-0631
111+
vp upgrade 0.0.0-e7cbd08c.20260221-0702
112112
vp --version
113113
# rollback to the previous version (should succeed after a real update)
114114
vp upgrade --rollback
@@ -168,7 +168,7 @@ jobs:
168168
169169
# Verify upgrade
170170
vp upgrade --check
171-
vp upgrade 0.0.0-b356849c.20260207-0631
171+
vp upgrade 0.0.0-e7cbd08c.20260221-0702
172172
vp --version
173173
vp upgrade --rollback
174174
vp --version
@@ -201,7 +201,7 @@ jobs:
201201
run: |
202202
# --check queries npm registry and prints update status
203203
vp upgrade --check
204-
vp upgrade 0.0.0-b356849c.20260207-0631
204+
vp upgrade 0.0.0-e7cbd08c.20260221-0702
205205
vp --version
206206
# rollback to the previous version (should succeed after a real update)
207207
vp upgrade --rollback
@@ -218,7 +218,7 @@ jobs:
218218
# $env:VITE_LOG = "trace"
219219
# test new command
220220
vp create vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
221-
cd hello && vp run build
221+
cd hello && vp run build && vp --version
222222
223223
- name: Verify bin setup on powershell
224224
shell: pwsh
@@ -261,7 +261,7 @@ jobs:
261261
262262
REM test new command
263263
vp create vite --no-interactive --no-agent -- hello-cmd --no-interactive -t vanilla
264-
cd hello-cmd && vp run build
264+
cd hello-cmd && vp run build && vp --version
265265
266266
- name: Verify bin setup on cmd
267267
shell: cmd
@@ -300,7 +300,7 @@ jobs:
300300
vp --help
301301
# test new command
302302
vp create vite --no-interactive --no-agent -- hello-bash --no-interactive -t vanilla
303-
cd hello-bash && vp run build
303+
cd hello-bash && vp run build && vp --version
304304
305305
- name: Verify bin setup on bash
306306
shell: bash

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)