mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
move fn to impl
This commit is contained in:
parent
62fd0d00b1
commit
27a98f9671
1 changed files with 25 additions and 23 deletions
|
@ -54,34 +54,36 @@ async fn parse_luaurc(_: &mlua::Lua, path: &PathBuf) -> Result<Option<Luaurc>, m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Searches for .luaurc recursively
|
impl Luaurc {
|
||||||
/// until an alias for the provided `RequireAlias` is found
|
/// Searches for .luaurc recursively
|
||||||
pub async fn resolve_require_alias<'lua>(
|
/// until an alias for the provided `RequireAlias` is found
|
||||||
lua: &'lua mlua::Lua,
|
pub async fn resolve_path<'lua>(
|
||||||
alias: &'lua RequireAlias,
|
lua: &'lua mlua::Lua,
|
||||||
) -> Result<PathBuf, mlua::Error> {
|
alias: &'lua RequireAlias,
|
||||||
let cwd = current_dir()?;
|
) -> Result<PathBuf, mlua::Error> {
|
||||||
let parent = cwd.join(get_parent_path(lua)?);
|
let cwd = current_dir()?;
|
||||||
let ancestors = parent.ancestors();
|
let parent = cwd.join(get_parent_path(lua)?);
|
||||||
|
let ancestors = parent.ancestors();
|
||||||
|
|
||||||
for path in ancestors {
|
for path in ancestors {
|
||||||
if path.starts_with(&cwd) {
|
if path.starts_with(&cwd) {
|
||||||
if let Some(luaurc) = parse_luaurc(lua, &parent.join(".luaurc")).await? {
|
if let Some(luaurc) = parse_luaurc(lua, &parent.join(".luaurc")).await? {
|
||||||
if let Some(aliases) = luaurc.aliases {
|
if let Some(aliases) = luaurc.aliases {
|
||||||
if let Some(alias_path) = aliases.get(&alias.alias) {
|
if let Some(alias_path) = aliases.get(&alias.alias) {
|
||||||
let resolved = path.join(alias_path.join(&alias.path));
|
let resolved = path.join(alias_path.join(&alias.path));
|
||||||
|
|
||||||
return Ok(resolved);
|
return Ok(resolved);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Err(mlua::Error::runtime(format!(
|
Err(mlua::Error::runtime(format!(
|
||||||
"Coudln't find the alias '{}' in any .luaurc file",
|
"Coudln't find the alias '{}' in any .luaurc file",
|
||||||
alias.alias
|
alias.alias
|
||||||
)))
|
)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue