diff --git a/lib/cli/src/commands/publish.rs b/lib/cli/src/commands/publish.rs index 192db4e0cb4..528e6dda822 100644 --- a/lib/cli/src/commands/publish.rs +++ b/lib/cli/src/commands/publish.rs @@ -50,8 +50,6 @@ pub struct Publish { #[derive(Debug, Error)] enum PublishError { - #[error("Cannot publish without a module.")] - NoModule, #[error("Unable to publish the \"{module}\" module because \"{}\" is not a file", path.display())] SourceMustBeFile { module: String, path: PathBuf }, #[error("Unable to load the bindings for \"{module}\" because \"{}\" doesn't exist", path.display())] @@ -115,7 +113,10 @@ impl Publish { builder .finish() .map_err(|e| anyhow::anyhow!("failed to finish .tar.gz builder: {e}"))?; - let tar_archive_data = builder.into_inner().map_err(|_| PublishError::NoModule)?; + let tar_archive_data = builder + .into_inner() + // NOTE: only fails if `Builder::finish()` was not called. + .expect("tar archive .finish() was not called"); let archive_name = "package.tar.gz".to_string(); let archive_dir = tempfile::TempDir::new()?; let archive_dir_path: &std::path::Path = archive_dir.as_ref(); @@ -172,7 +173,7 @@ fn construct_tar_gz( cwd: &Path, ) -> Result<(Option, Option), anyhow::Error> { let package = &manifest.package; - let modules = manifest.module.as_ref().ok_or(PublishError::NoModule)?; + let modules = manifest.module.as_deref().unwrap_or_default(); let readme = match package.readme.as_ref() { None => None,