Move Cargo.toml check to run_prepare_step

This commit is contained in:
AriusX7 2021-01-28 16:23:52 +05:30 committed by Ryan Leckey
parent 264cb09528
commit ed20639d47

View File

@ -23,12 +23,6 @@ pub fn run(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()
data: QueryData,
}
anyhow::ensure!(
Path::new("Cargo.toml").exists(),
r#"Failed to read `Cargo.toml`.
hint: This command only works in the manifest directory of a Cargo package."#
);
let db_kind = get_db_kind(url)?;
let data = run_prepare_step(merge, cargo_args)?;
@ -89,6 +83,12 @@ pub fn check(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<
}
fn run_prepare_step(merge: bool, cargo_args: Vec<String>) -> anyhow::Result<QueryData> {
anyhow::ensure!(
Path::new("Cargo.toml").exists(),
r#"Failed to read `Cargo.toml`.
hint: This command only works in the manifest directory of a Cargo package."#
);
// path to the Cargo executable
let cargo = env::var("CARGO")
.context("`prepare` subcommand may only be invoked as `cargo sqlx prepare`")?;