Skip to content

Commit

Permalink
lualoader: Add a loaded hook for others to execute upon config load
Browse files Browse the repository at this point in the history
This will not be executed on reload, though later work could allow for that.
It's intended/expected that later work won't generally need to happen on
every config load, just once (for, e.g., menu initialization) or just when
config is reloaded but not upon the initial load.
  • Loading branch information
kevans91 committed Jun 6, 2018
1 parent cbb009b commit 7aba5b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions stand/lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function config.selectKernel(kernel)
config.kernel_selected = kernel
end

function config.load(file)
function config.load(file, reloading)
if not file then
file = "/boot/defaults/loader.conf"
end
Expand All @@ -485,13 +485,16 @@ function config.load(file)
config.module_path = loader.getenv("module_path")
local verbose = loader.getenv("verbose_loading") or "no"
config.verbose = verbose:lower() == "yes"
if not reloading then
hook.runAll("config.loaded")
end
end

-- Reload configuration
function config.reload(file)
modules = {}
restoreEnv()
config.load(file)
config.load(file, true)
hook.runAll("config.reloaded")
end

Expand All @@ -512,5 +515,6 @@ function config.loadelf()
end
end

hook.registerType("config.loaded")
hook.registerType("config.reloaded")
return config

0 comments on commit 7aba5b2

Please sign in to comment.