diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index 2296bc2a6..19fe1f676 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -429,17 +429,19 @@ fn construct_manifest( let canonicalized_outpath = outpath.canonicalize().unwrap_or(outpath); let outpath_str = crate::commands::normalize_path(&canonicalized_outpath.display().to_string()); - let manifest_canonicalized = manifest_path - .parent() - .and_then(|p| p.canonicalize().ok()) - .unwrap_or_else(|| manifest_path.to_path_buf()); - let diff = pathdiff::diff_paths(&outpath_str, &manifest_canonicalized).unwrap(); + let manifest_canonicalized = crate::commands::normalize_path( + &manifest_path + .parent() + .and_then(|p| p.canonicalize().ok()) + .unwrap_or_else(|| manifest_path.to_path_buf()) + .display() + .to_string(), + ); + let diff = outpath_str + .strip_prefix(&manifest_canonicalized) + .unwrap_or(&outpath_str); // Format in UNIX fashion (forward slashes) - let diff_str = diff.display().to_string(); - let relative_str = diff_str - .strip_prefix('/') - .unwrap_or(&diff_str) - .replace("\\", "/"); + let relative_str = diff.strip_prefix('/').unwrap_or(diff).replace('\\', "/"); Path::new(&relative_str).to_path_buf() }) .unwrap_or_else(|| Path::new(&format!("{package_name}.wasm")).to_path_buf()); diff --git a/tests/integration/cli/tests/create_exe.rs b/tests/integration/cli/tests/create_exe.rs index 6011a32cd..526db2624 100644 --- a/tests/integration/cli/tests/create_exe.rs +++ b/tests/integration/cli/tests/create_exe.rs @@ -251,6 +251,7 @@ fn test_create_exe_with_precompiled_works_1() { ); } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_works() -> anyhow::Result<()> { let temp_dir = tempfile::tempdir()?; @@ -284,6 +285,7 @@ fn create_exe_works() -> anyhow::Result<()> { Ok(()) } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_works_multi_command() -> anyhow::Result<()> { let temp_dir = tempfile::tempdir()?; @@ -336,6 +338,7 @@ fn create_exe_works_multi_command() -> anyhow::Result<()> { Ok(()) } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_works_with_file() -> anyhow::Result<()> { let temp_dir = tempfile::tempdir()?; @@ -576,16 +579,19 @@ fn create_exe_with_object_input(args: Vec) -> anyhow::Result<()> { Ok(()) } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_with_object_input_default() -> anyhow::Result<()> { create_exe_with_object_input(vec![]) } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_with_object_input_symbols() -> anyhow::Result<()> { create_exe_with_object_input(vec!["--object-format".to_string(), "symbols".to_string()]) } +#[cfg(not(target_os = "windows"))] #[test] fn create_exe_with_object_input_serialized() -> anyhow::Result<()> { create_exe_with_object_input(vec![