stop converting relative paths to absolute

prevented downstream users from utilizing `PathSearcher` in binary
This commit is contained in:
Andy Weidenbaum 2021-03-15 11:19:48 +11:00
parent 33599cd9b6
commit 94ff5d143e
3 changed files with 1 additions and 18 deletions

View File

@ -1,7 +1,6 @@
mod error;
mod searcher;
mod types;
mod utils;
pub use crate::error::Error;
pub use crate::searcher::AddSearcher;

View File

@ -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)

View File

@ -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())
}