From 110d1b336f836b2a24c09a752eb714a4c2dd523e Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 10 Apr 2024 07:55:25 -0300 Subject: [PATCH] fix(packager): exit with error if config not found --- .changes/error-out-if-no-config.md | 5 +++++ Cargo.lock | 4 ++-- crates/packager/src/cli/mod.rs | 3 +-- crates/packager/src/error.rs | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changes/error-out-if-no-config.md diff --git a/.changes/error-out-if-no-config.md b/.changes/error-out-if-no-config.md new file mode 100644 index 00000000..eacac4f7 --- /dev/null +++ b/.changes/error-out-if-no-config.md @@ -0,0 +1,5 @@ +--- +"cargo-packager": patch +--- + +Error out if we cannot find a configuration file. diff --git a/Cargo.lock b/Cargo.lock index 01f83774..b59bc92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "cargo-packager" -version = "0.6.1" +version = "0.7.0" dependencies = [ "ar", "base64 0.21.7", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "cargo-packager-resource-resolver" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cargo-packager-utils", "heck 0.4.1", diff --git a/crates/packager/src/cli/mod.rs b/crates/packager/src/cli/mod.rs index 2a925a1c..b612eb7e 100644 --- a/crates/packager/src/cli/mod.rs +++ b/crates/packager/src/cli/mod.rs @@ -135,8 +135,7 @@ fn run_cli(cli: Cli) -> Result<()> { }; if configs.is_empty() { - tracing::debug!("Couldn't detect a valid configuration file or all configurations are disabled! Nothing to do here."); - return Ok(()); + return Err(crate::Error::NoConfig); } let cli_out_dir = cli.out_dir.as_ref().map(dunce::canonicalize).transpose()?; diff --git a/crates/packager/src/error.rs b/crates/packager/src/error.rs index b1557e49..a73d6440 100644 --- a/crates/packager/src/error.rs +++ b/crates/packager/src/error.rs @@ -32,6 +32,9 @@ pub enum Error { /// Target triple environment error #[error("Unable to determine target-environment")] Environment, + /// No config file found. + #[error("Couldn't detect a valid configuration file or all configurations are disabled.")] + NoConfig, /// I/O errors. #[error(transparent)] Io(#[from] std::io::Error),