mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: strip .luau extension from require paths
This commit is contained in:
parent
91a3a9b122
commit
f7d2d7cbb0
2 changed files with 38 additions and 6 deletions
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Link dependencies before type extraction to support more use cases by @daimond113
|
- Link dependencies before type extraction to support more use cases by @daimond113
|
||||||
|
- Strip `.luau` extension from linker modules' require paths to comply with Luau by @daimond113
|
||||||
|
|
||||||
## [0.5.0-rc.14] - 2024-11-30
|
## [0.5.0-rc.14] - 2024-11-30
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -69,10 +69,29 @@ pub fn generate_lib_linking_module<I: IntoIterator<Item = S>, S: AsRef<str>>(
|
||||||
fn luau_style_path(path: &Path) -> String {
|
fn luau_style_path(path: &Path) -> String {
|
||||||
let path = path
|
let path = path
|
||||||
.components()
|
.components()
|
||||||
.filter_map(|ct| match ct {
|
.zip(
|
||||||
|
path.components()
|
||||||
|
.skip(1)
|
||||||
|
.map(Some)
|
||||||
|
.chain(std::iter::repeat(None)),
|
||||||
|
)
|
||||||
|
.filter_map(|(ct, next_ct)| match ct {
|
||||||
Component::CurDir => Some(".".to_string()),
|
Component::CurDir => Some(".".to_string()),
|
||||||
Component::ParentDir => Some("..".to_string()),
|
Component::ParentDir => Some("..".to_string()),
|
||||||
Component::Normal(part) => Some(format!("{}", part.to_string_lossy())),
|
Component::Normal(part) => {
|
||||||
|
let str = part.to_string_lossy();
|
||||||
|
|
||||||
|
Some(
|
||||||
|
(if next_ct.is_some() {
|
||||||
|
&str
|
||||||
|
} else {
|
||||||
|
str.strip_suffix(".luau")
|
||||||
|
.or_else(|| str.strip_suffix(".lua"))
|
||||||
|
.unwrap_or(&str)
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
@ -126,14 +145,26 @@ pub fn get_lib_require_path(
|
||||||
|
|
||||||
let path = path
|
let path = path
|
||||||
.components()
|
.components()
|
||||||
.filter_map(|component| match component {
|
.zip(
|
||||||
|
path.components()
|
||||||
|
.skip(1)
|
||||||
|
.map(Some)
|
||||||
|
.chain(std::iter::repeat(None)),
|
||||||
|
)
|
||||||
|
.filter_map(|(component, next_comp)| match component {
|
||||||
Component::ParentDir => Some(".Parent".to_string()),
|
Component::ParentDir => Some(".Parent".to_string()),
|
||||||
Component::Normal(part) if part != "init.lua" && part != "init.luau" => {
|
Component::Normal(part) if part != "init.lua" && part != "init.luau" => {
|
||||||
|
let str = part.to_string_lossy();
|
||||||
|
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"[{:?}]",
|
"[{:?}]",
|
||||||
part.to_string_lossy()
|
if next_comp.is_some() {
|
||||||
.trim_end_matches(".lua")
|
&str
|
||||||
.trim_end_matches(".luau")
|
} else {
|
||||||
|
str.strip_suffix(".luau")
|
||||||
|
.or_else(|| str.strip_suffix(".lua"))
|
||||||
|
.unwrap_or(&str)
|
||||||
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
Loading…
Reference in a new issue