Fixed sea-orm-cli exit status (#1402)

This commit is contained in:
Diwakar Gupta 2023-01-19 13:10:29 +05:30 committed by GitHub
parent e6206c9143
commit 9c6e5c1fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -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());
}
}
}
}

View File

@ -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());
}
}
}