made require search the pkgfs if available

This commit is contained in:
Izaya 2020-06-06 19:49:26 +10:00
parent 89ab49faf6
commit 45c70cbaa6
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ _G.package = {}
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer} package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
function require(f,force) -- string boolean -- table -- searches for a library with name *f* and returns what the library returns, if possible. if *force* is set, loads the library even if it is cached function require(f,force) -- string boolean -- table -- searches for a library with name *f* and returns what the library returns, if possible. if *force* is set, loads the library even if it is cached
if not package.loaded[f] or force then if not package.loaded[f] or force then
local lib = os.getenv("LIB") or "/boot/lib" local lib = os.getenv("LIB") or "/boot/lib\n/pkg/lib"
for d in lib:gmatch("[^\n]+") do for d in lib:gmatch("[^\n]+") do
if fs.exists(d.."/"..f) then if fs.exists(d.."/"..f) then
package.loaded[f] = runfile(d.."/"..f) package.loaded[f] = runfile(d.."/"..f)