Skip to content

Commit

Permalink
Fixed sea-orm-cli exit status (SeaQL#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diwakar-Gupta authored and denwong47 committed Jan 20, 2023
1 parent 9c456f1 commit 727a1c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions sea-orm-cli/src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ pub async fn run_generate_command(

// Format each of the files
for OutputFile { name, .. } in output.files.iter() {
Command::new("rustfmt")
.arg(dir.join(name))
.spawn()?
.wait()?;
let exit_status = Command::new("rustfmt").arg(dir.join(name)).status()?; // Get the status code
if !exit_status.success() {
// Propagate the error if any
return Err(format!("Fail to format file `{name}`").into());
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion sea-orm-cli/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ pub fn run_migrate_command(
}
// Run migrator CLI on user's behalf
println!("Running `cargo {}`", args.join(" "));
Command::new("cargo").args(args).spawn()?.wait()?;
let exit_status = Command::new("cargo").args(args).status()?; // Get the status code
if !exit_status.success() {
// Propagate the error if any
return Err("Fail to run migration".into());
}
}
}

Expand Down

0 comments on commit 727a1c4

Please sign in to comment.