mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: correctly generate require paths
This commit is contained in:
parent
7f8b2761ab
commit
d8cd78e7e2
2 changed files with 18 additions and 18 deletions
|
@ -65,19 +65,19 @@ pub fn generate_lib_linking_module<I: IntoIterator<Item = S>, S: AsRef<str>>(
|
|||
}
|
||||
|
||||
fn luau_style_path(path: &Path) -> String {
|
||||
path.components()
|
||||
.enumerate()
|
||||
.filter_map(|(i, ct)| match ct {
|
||||
Component::ParentDir => Some(if i == 0 {
|
||||
".".to_string()
|
||||
} else {
|
||||
"..".to_string()
|
||||
}),
|
||||
let path = path
|
||||
.components()
|
||||
.filter_map(|ct| match ct {
|
||||
Component::CurDir => Some(".".to_string()),
|
||||
Component::ParentDir => Some("..".to_string()),
|
||||
Component::Normal(part) => Some(format!("{}", part.to_string_lossy())),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("/")
|
||||
.join("/");
|
||||
|
||||
let require = format!("./{path}");
|
||||
format!("{require:?}")
|
||||
}
|
||||
|
||||
pub fn get_lib_require_path(
|
||||
|
@ -115,10 +115,10 @@ pub fn get_lib_require_path(
|
|||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
|
||||
return format!("script{path}");
|
||||
return format!("script.Parent{path}");
|
||||
};
|
||||
|
||||
format!("{:?}", luau_style_path(&path))
|
||||
luau_style_path(&path)
|
||||
}
|
||||
|
||||
pub fn generate_bin_linking_module(path: &str) -> String {
|
||||
|
@ -133,5 +133,5 @@ pub fn get_bin_require_path(
|
|||
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
||||
let path = bin_file.to_path(path);
|
||||
|
||||
format!("{:?}", luau_style_path(&path))
|
||||
luau_style_path(&path)
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ impl Project {
|
|||
let module = generator::generate_lib_linking_module(
|
||||
&generator::get_lib_require_path(
|
||||
&node.target.kind(),
|
||||
&linker_file,
|
||||
&base_folder,
|
||||
lib_file,
|
||||
&container_folder,
|
||||
node.node.pkg_ref.use_new_structure(),
|
||||
|
@ -138,7 +138,7 @@ impl Project {
|
|||
|
||||
let module = generator::generate_bin_linking_module(
|
||||
&generator::get_bin_require_path(
|
||||
&linker_file,
|
||||
&base_folder,
|
||||
bin_file,
|
||||
&container_folder,
|
||||
),
|
||||
|
@ -165,16 +165,16 @@ impl Project {
|
|||
continue;
|
||||
};
|
||||
|
||||
let linker_file = create_and_canonicalize(
|
||||
let linker_folder = create_and_canonicalize(
|
||||
container_folder
|
||||
.join(dependency_node.node.base_folder(node.target.kind(), false)),
|
||||
)?
|
||||
.join(format!("{dependency_alias}.luau"));
|
||||
)?;
|
||||
let linker_file = linker_folder.join(format!("{dependency_alias}.luau"));
|
||||
|
||||
let module = generator::generate_lib_linking_module(
|
||||
&generator::get_lib_require_path(
|
||||
&dependency_node.target.kind(),
|
||||
&linker_file,
|
||||
&linker_folder,
|
||||
lib_file,
|
||||
&dependency_node.node.container_folder(
|
||||
&packages_container_folder,
|
||||
|
|
Loading…
Reference in a new issue