Skip to content

Commit

Permalink
Allow publishing packages without a module
Browse files Browse the repository at this point in the history
Modify the Wasmer package build logic to allow packages without a
module.

These packages are perfectly valid and useful (pure fs package, module
comes from dependencies, ...)
  • Loading branch information
theduke committed Mar 28, 2023
1 parent 29d2830 commit bc65b66
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/registry/src/package/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ pub struct Publish {

#[derive(Debug, Error)]
enum PackageBuildError {
#[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())]
Expand Down Expand Up @@ -108,9 +106,7 @@ 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(|_| PackageBuildError::NoModule)?;
let tar_archive_data = builder.into_inner().expect("tar archive was not finalized");
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();
Expand Down Expand Up @@ -166,10 +162,7 @@ fn construct_tar_gz(
cwd: &Path,
) -> Result<(Option<String>, Option<String>), anyhow::Error> {
let package = &manifest.package;
let modules = manifest
.module
.as_ref()
.ok_or(PackageBuildError::NoModule)?;
let modules = manifest.module.as_deref().unwrap_or_default();

let readme = match package.readme.as_ref() {
None => None,
Expand Down

0 comments on commit bc65b66

Please sign in to comment.