You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to overwrite the behavior of the require function. I want to be able to manually provide the lua functions (preferably via a string rather than from a file on the filesystem) since I am running in a very isolated environment that should have no filesystem access. How can I do this?
The text was updated successfully, but these errors were encountered:
This is what I came up with. It seems to work, but I'm not sure if it'll be reliable in the long run
self.lua.globals().require=self.requiredefrequire(self, module_name):
# Check if the module is already loadedifmodule_nameinself.lua.globals().package.loaded:
returnself.lua.globals().package.loaded[module_name]
# Try to load the .lua file from our custom directory (for debugging, we can get the source of the lua module however we want)try:
withopen(f"/tmp/{module_name}.lua", "r") asf:
module_code=f.read()
exceptFileNotFoundError:
raiseModuleNotFoundError(f"module '{module_name}' not found")
# Return the moduleself.lua.globals().package.loaded[module_name] =self.lua.execute(module_code)
returnself.lua.globals().package.loaded[module_name]
Also, are there docs for this library? I can't seem to find any and they would really help
I would like to be able to overwrite the behavior of the require function. I want to be able to manually provide the lua functions (preferably via a string rather than from a file on the filesystem) since I am running in a very isolated environment that should have no filesystem access. How can I do this?
The text was updated successfully, but these errors were encountered: