mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Fixed module's table not updating in lume.hotswap()
Changed the returned values from pcall() in lume.hotswap() to be handled correctly -- the second return value being the wrapped-function's first return value. This bug would effect hotswapped modules which used the modern approach of returning a table rather than creating globals.
This commit is contained in:
parent
83a051aadb
commit
05828bd840
3
lume.lua
3
lume.lua
@ -266,12 +266,13 @@ function lume.hotswap(modname)
|
||||
if type(v) == "table" then update(old[k], v) else old[k] = v end
|
||||
end
|
||||
end
|
||||
local oldmod = pcall(require, modname) or nil
|
||||
local err = nil
|
||||
local function onerror(e)
|
||||
for k, v in pairs(_G) do _G[k] = oldglobal[k] end
|
||||
err = lume.trim(e)
|
||||
end
|
||||
local ok, oldmod = pcall(require, modname)
|
||||
oldmod = ok and oldmod or nil
|
||||
xpcall(function()
|
||||
package.loaded[modname] = nil
|
||||
local newmod = require(modname)
|
||||
|
Loading…
Reference in New Issue
Block a user