From 194687ca67a56d973e3408e95d5f5104032abd65 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Sun, 24 Mar 2024 19:27:10 +0100 Subject: [PATCH] fix(wally-compat): :bug: correct linking file paths --- src/dependencies/mod.rs | 9 ++++++--- src/linking_file.rs | 13 ++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/dependencies/mod.rs b/src/dependencies/mod.rs index a0a1091..831bc6e 100644 --- a/src/dependencies/mod.rs +++ b/src/dependencies/mod.rs @@ -259,7 +259,7 @@ pub enum ConvertManifestsError { #[cfg(feature = "wally")] #[error("error parsing the sourcemap")] Parse(#[from] serde_json::Error), - + /// An error that occurred while writing the manifest #[error("error writing the manifest")] Write(#[from] serde_yaml::Error), @@ -358,8 +358,11 @@ impl Project { .is_some_and(|ext| ext == "lua" || ext == "luau") }) .or_else(|| Some(relative_path::RelativePathBuf::from("true"))); - - serde_yaml::to_writer(&std::fs::File::create(&source.join(crate::MANIFEST_FILE_NAME))?, &manifest)?; + + serde_yaml::to_writer( + &std::fs::File::create(&source.join(crate::MANIFEST_FILE_NAME))?, + &manifest, + )?; } } diff --git a/src/linking_file.rs b/src/linking_file.rs index 80a8eb4..590843c 100644 --- a/src/linking_file.rs +++ b/src/linking_file.rs @@ -1,7 +1,6 @@ use std::{ collections::HashSet, fs::{read_to_string, write}, - iter, path::{Component, Path, PathBuf}, }; @@ -185,8 +184,9 @@ pub(crate) fn link, Q: AsRef>( "script.Parent".to_string() }; - let path = iter::once(Ok(beginning)) - .chain(path.components().map(|component| { + let mut components = path + .components() + .map(|component| { Ok(match component { Component::ParentDir => ".Parent".to_string(), Component::Normal(part) => format!( @@ -195,8 +195,11 @@ pub(crate) fn link, Q: AsRef>( ), _ => unreachable!("invalid path component"), }) - })) - .collect::>()?; + }) + .collect::, LinkingError>>()?; + components.pop(); + + let path = beginning + &components.join("") + &format!("[{name:?}]"); debug!( "writing linking file for {} with import `{path}` to {}",