stop converting relative paths to absolute
prevented downstream users from utilizing `PathSearcher` in binary
This commit is contained in:
parent
33599cd9b6
commit
94ff5d143e
@ -1,7 +1,6 @@
|
||||
mod error;
|
||||
mod searcher;
|
||||
mod types;
|
||||
mod utils;
|
||||
|
||||
pub use crate::error::Error;
|
||||
pub use crate::searcher::AddSearcher;
|
||||
|
@ -6,7 +6,6 @@ use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::types::Result;
|
||||
use crate::utils;
|
||||
|
||||
/// Stores Lua modules indexed by module name, and provides an `rlua::MetaMethod`
|
||||
/// to enable `require`ing the stored modules by name in an `rlua::Context`.
|
||||
@ -113,17 +112,8 @@ where
|
||||
methods.add_meta_method(MetaMethod::Call, |lua_ctx, this, name: String| {
|
||||
match this.modules.get(&name) {
|
||||
Some(ref path) => {
|
||||
let path = path.as_ref();
|
||||
|
||||
// Ensure `path` is relative to `$CARGO_MANIFEST_DIR`.
|
||||
let path = if path.is_relative() {
|
||||
utils::runtime_root().join(path)
|
||||
} else {
|
||||
path.to_path_buf()
|
||||
};
|
||||
|
||||
let path = path.as_ref().to_path_buf();
|
||||
let content = (this.transform)(path)?;
|
||||
|
||||
Ok(Value::Function(
|
||||
lua_ctx
|
||||
.load(&content)
|
||||
|
@ -1,6 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Return the value of `$CARGO_MANIFEST_DIR` at runtime.
|
||||
pub(crate) fn runtime_root() -> PathBuf {
|
||||
PathBuf::new().join(std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
}
|
Loading…
Reference in New Issue
Block a user