mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
fix(issue #558)
- check the existance of `Cargo.toml` at current working directory before checking 'DATABASE_URL' environment variable
This commit is contained in:
parent
9b26d45344
commit
48a55a407b
1 changed files with 9 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
|||
use crate::opt::{Command, DatabaseCommand, MigrateCommand};
|
||||
use anyhow::anyhow;
|
||||
use anyhow::{anyhow, bail};
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
mod database;
|
||||
// mod migration;
|
||||
|
@ -13,6 +14,13 @@ mod prepare;
|
|||
pub use crate::opt::Opt;
|
||||
|
||||
pub async fn run(opt: Opt) -> anyhow::Result<()> {
|
||||
if !Path::new("Cargo.toml").exists() {
|
||||
bail!(
|
||||
r#"Failed to read `Cargo.toml`.
|
||||
hint: This command only works in the manifest directory of a Cargo package."#
|
||||
);
|
||||
}
|
||||
|
||||
dotenv().ok();
|
||||
|
||||
let database_url = match opt.database_url {
|
||||
|
|
Loading…
Reference in a new issue