Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/binding/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ export interface JsCommandResolvedResult {
* Errors from JavaScript resolvers are converted to specific error types
* (e.g., `LintFailed`, `ViteError`) to provide better error messages.
*/
export declare function run(options: CliOptions): Promise<void>
export declare function run(options: CliOptions): Promise<number>
6 changes: 3 additions & 3 deletions packages/cli/binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static BUILTIN_COMMANDS: &[&str] = &["lint", "fmt", "build", "test", "doc", "lib
/// Errors from JavaScript resolvers are converted to specific error types
/// (e.g., `LintFailed`, `ViteError`) to provide better error messages.
#[napi]
pub async fn run(options: CliOptions) -> Result<()> {
pub async fn run(options: CliOptions) -> Result<i32> {
let args = parse_args();
// Use provided cwd or current directory
let mut cwd = current_dir()?;
Expand Down Expand Up @@ -198,11 +198,11 @@ pub async fn run(options: CliOptions) -> Result<()> {
.await;

match result {
Ok(exit_status) => std::process::exit(exit_status.code().unwrap_or(1)),
Ok(exit_status) => Ok(exit_status.code().unwrap_or(1)),
Err(e) => {
match e {
// Standard exit code for Ctrl+C
Error::UserCancelled => std::process::exit(130),
Error::UserCancelled => Ok(130),
_ => {
// Convert Rust errors to NAPI errors for JavaScript
tracing::error!("Rust error: {:?}", e);
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ run({
test, // Resolves vitest binary for test commands
doc, // Resolves vitepress binary for doc commands
resolveUniversalViteConfig,
}).catch((err) => {
console.error('[vite+] run error:', err);
process.exit(1);
});
}).then((exitCode) => {
process.exit(exitCode);
})
.catch((err) => {
Comment thread
Brooooooklyn marked this conversation as resolved.
console.error('[vite+] run error:', err);
process.exit(1);
});
Loading