make sure the load function is called on dep reloading

This commit is contained in:
2024-07-25 20:01:23 -04:00
parent d7a08ca820
commit 30e7e05771

View File

@ -11,7 +11,7 @@ local logger = require("dep.log").global
local proc = require("dep.proc") local proc = require("dep.proc")
local initialized, perf, config_path, base_dir local initialized, perf, config_path, base_dir
local packages, root local packages, root, load
local function bench(name, code, ...) local function bench(name, code, ...)
local start = os.clock() local start = os.clock()
@ -396,6 +396,16 @@ local function reload()
end end
local function reload_all() local function reload_all()
-- recall the load function
if load and type(load) == "function" then
local ok, ret = pcall(load)
if ok and type(ret) == "table" then
register_recursive(ret)
else
logger:log("error", ret)
end
end
for i = 1, #packages do for i = 1, #packages do
local package = packages[i] local package = packages[i]
package.loaded, package.subtree_loaded = false, false package.loaded, package.subtree_loaded = false, false
@ -832,6 +842,7 @@ return setmetatable({
if config["load"] and type(config["load"]) == "function" then if config["load"] and type(config["load"]) == "function" then
local ok, ret = pcall(config["load"]) local ok, ret = pcall(config["load"])
if ok and type(ret) == "table" then if ok and type(ret) == "table" then
load = config["load"]
register_recursive(ret) register_recursive(ret)
else else
logger:log("error", ret) logger:log("error", ret)