Skip to content

Commit 82e12ea

Browse files
committed
exit from rust side
1 parent 65d3294 commit 82e12ea

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

packages/cli/binding/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ static BUILTIN_COMMANDS: &[&str] = &["lint", "fmt", "build", "test", "doc", "lib
102102
/// Errors from JavaScript resolvers are converted to specific error types
103103
/// (e.g., `LintFailed`, `ViteError`) to provide better error messages.
104104
#[napi]
105-
pub async fn run(options: CliOptions) -> Result<i32> {
105+
pub async fn run(options: CliOptions) {
106106
let args = parse_args();
107107
// Use provided cwd or current directory
108-
let mut cwd = current_dir()?;
108+
let mut cwd = current_dir().expect("Failed to get current directory");
109109
if let Some(options_cwd) = options.cwd {
110110
cwd.push(options_cwd);
111111
}
@@ -202,24 +202,24 @@ pub async fn run(options: CliOptions) -> Result<i32> {
202202
)
203203
.await;
204204

205-
dbg!(&result);
206-
207205
tracing::debug!("Result: {result:?}");
208206

209-
match result {
210-
Ok(exit_status) => Ok(exit_status.code().unwrap_or(1)),
207+
let exit_code = match result {
208+
Ok(exit_status) => exit_status.code().unwrap_or(1),
211209
Err(e) => {
212210
match e {
213211
// Standard exit code for Ctrl+C
214-
Error::UserCancelled => Ok(130),
212+
Error::UserCancelled => 130,
215213
_ => {
216214
// Convert Rust errors to NAPI errors for JavaScript
217215
tracing::error!("Rust error: {:?}", e);
218-
Err(anyhow::Error::from(e).into())
216+
eprintln!("[vite+] run error: {:?}", e);
217+
1
219218
}
220219
}
221220
}
222-
}
221+
};
222+
std::process::exit(exit_code);
223223
}
224224

225225
/// Convert JavaScript errors to Rust lint errors

packages/cli/src/bin.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,4 @@ run({
4040
test, // Resolves vitest binary for test commands
4141
doc, // Resolves vitepress binary for doc commands
4242
resolveUniversalViteConfig,
43-
}).then((exitCode) => {
44-
process.exit(exitCode);
45-
})
46-
.catch((err) => {
47-
console.error('[vite+] run error:', err);
48-
process.exit(1);
49-
});
43+
});

0 commit comments

Comments
 (0)