diff --git a/packages/lib/src/globals/require.rs b/packages/lib/src/globals/require.rs index e4269dd..b8c9e28 100644 --- a/packages/lib/src/globals/require.rs +++ b/packages/lib/src/globals/require.rs @@ -44,7 +44,9 @@ pub fn create(lua: &'static Lua) -> LuaResult { let require_get_abs_rel_paths = lua .create_function( |_, (require_pwd, require_source, require_path): (String, String, String)| { - // TODO: Special case for @lune prefix here + if require_path.starts_with('@') { + return Ok((require_path.clone(), require_path)); + } let path_relative_to_pwd = PathBuf::from( &require_source .trim_start_matches("[string \"") @@ -76,7 +78,22 @@ pub fn create(lua: &'static Lua) -> LuaResult { // were async then one lua script may require a module during the file reading process let require_get_loaded_file = lua.create_function( |lua: &Lua, (path_absolute, path_relative): (String, String)| { - // TODO: Check for @lune prefix here and try to load a builtin module + // Check if we got a special require path starting with an @ + if path_absolute == path_relative && path_absolute.starts_with('@') { + return match path_absolute { + p if p.starts_with("@lune/") => { + let _module_name = p.strip_prefix("@lune/").unwrap(); + // TODO: Return builtin module + Err(LuaError::RuntimeError( + "Builtin require paths prefixed by '@' are not yet supported" + .to_string(), + )) + } + _ => Err(LuaError::RuntimeError( + "Custom require paths prefixed by '@' are not yet supported".to_string(), + )), + }; + } // Use a name without extensions for loading the chunk, the // above code assumes the require path is without extensions let path_relative_no_extension = path_relative