refactor(init): return a stub for imports with no return

Modules that define globals or directly add several functions to the
lib namespace currently need to return empty functions (i.e. locales).
This commit is contained in:
Linden
2022-05-12 00:02:25 +10:00
parent 6a8ebb5a0d
commit ef4ca56889

View File

@@ -47,7 +47,8 @@ local function loadModule(self, module)
if err then
error(('\n^1Error importing module (%s): %s^0'):format(dir, err), 3)
else
rawset(self, module, chunk())
local result = chunk() or function() end
rawset(self, module, result)
return self[module]
end
end
@@ -90,9 +91,6 @@ lib = setmetatable({
}, {
__index = call,
__call = call,
__newindex = function()
error('Cannot set index on lib')
end,
})
local intervals = {}