From 61bcd8720de3f9e8d57dd2108af5651292250656 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Thu, 19 May 2022 11:19:51 -0600 Subject: [PATCH] warn if script is present but manifest does not require one --- backend/src/s9pk/mod.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/src/s9pk/mod.rs b/backend/src/s9pk/mod.rs index 51e13d340..177053218 100644 --- a/backend/src/s9pk/mod.rs +++ b/backend/src/s9pk/mod.rs @@ -123,14 +123,18 @@ pub async fn pack(#[context] ctx: SdkContext, #[arg] path: Option) -> R }) .scripts({ let script_path = path.join(manifest.assets.scripts_path()).join("embassy.js"); - if manifest.package_procedures().any(|a| a.is_script()) { - if script_path.exists() { - Some(File::open(script_path).await?) - } else { + let needs_script = manifest.package_procedures().any(|a| a.is_script()); + let has_script = script_path.exists(); + match (needs_script, has_script) { + (true, true) => Some(File::open(script_path).await?), + (true, false) => { return Err(Error::new(eyre!("Script is declared in manifest, but no such script exists at ./scripts/embassy.js"), ErrorKind::Pack).into()) } - } else { - None + (false, true) => { + tracing::warn!("Manifest does not declare any actions that use scripts, but a script exists at ./scripts/embassy.js"); + None + } + (false, false) => None } }) .build()