From db4277ef524de14fc7e76d167ae7af744fddc2fc Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 Apr 2024 12:49:56 -0600 Subject: [PATCH] fix kebab case issue (#274) Signed-off-by: Brian H --- src/bindings.rs | 3 ++- tests/build.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/bindings.rs b/src/bindings.rs index c12d19e4..b9b646cf 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -7,6 +7,7 @@ use crate::{ }; use anyhow::{bail, Context, Result}; use cargo_component_core::registry::DecodedDependency; +use heck::ToKebabCase; use indexmap::{IndexMap, IndexSet}; use semver::Version; use std::{ @@ -445,7 +446,7 @@ impl<'a> BindingsGenerator<'a> { fn target_empty_world(resolution: &PackageDependencyResolution) -> (Resolve, WorldId) { let mut resolve = Resolve::default(); - let name = resolution.metadata.name.clone(); + let name = resolution.metadata.name.to_kebab_case(); let pkg_name = PackageName { namespace: "component".to_string(), name: name.clone(), diff --git a/tests/build.rs b/tests/build.rs index 638aaf00..2999b9bd 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -27,6 +27,21 @@ fn it_builds_debug() -> Result<()> { Ok(()) } +#[test] +fn it_builds_a_bin_project_with_snake_case() -> Result<()> { + let project = Project::new_bin("hello_world")?; + + project + .cargo_component("build --release") + .assert() + .stderr(contains("Finished release [optimized] target(s)")) + .success(); + + validate_component(&project.release_wasm("hello_world"))?; + + Ok(()) +} + #[test] fn it_builds_a_bin_project() -> Result<()> { let project = Project::new_bin("foo")?;