allow for modules to keep track of the packages they've declared
This commit is contained in:
@ -7,6 +7,7 @@ local packager = require("dep.package")
|
||||
---@field desc string description of the module
|
||||
---@field path string path to the module
|
||||
---@field mod table the module
|
||||
---@field packages package[] all packages registed from the module
|
||||
local module = {}
|
||||
|
||||
--- Initialize a module
|
||||
@ -55,6 +56,9 @@ function module:new(modpath, prefix, overrides)
|
||||
return false
|
||||
end
|
||||
|
||||
-- ensure that the module contains the packages that it's created
|
||||
self.packages = err
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -452,8 +452,10 @@ end
|
||||
--- recurse over all packages and register them
|
||||
---@param speclist speclist table of specs
|
||||
---@param overrides spec? a package spec that is used to override options
|
||||
---@return package[] packages
|
||||
function package.register_speclist(speclist, overrides)
|
||||
overrides = overrides or {}
|
||||
local packages_from_speclist = {}
|
||||
|
||||
-- recurse the packages
|
||||
local over = overrides
|
||||
@ -468,8 +470,19 @@ function package.register_speclist(speclist, overrides)
|
||||
-- While a package can fail to load we just don't care, it will work itself
|
||||
-- out. The goal is to make sure every plugin that can load does load, not
|
||||
-- keep working plugins from loading because an unrelated one doesn't load.
|
||||
package:new(spec, over)
|
||||
local pkg = package:new(spec, over)
|
||||
if not pkg then
|
||||
goto continue
|
||||
end
|
||||
|
||||
-- we store all the packages in a table so that the caller may keep track of
|
||||
-- their packages, this is not required and therefore the return value may
|
||||
-- be discarded
|
||||
table.insert(packages_from_speclist, pkg)
|
||||
::continue::
|
||||
end
|
||||
|
||||
return packages_from_speclist
|
||||
end
|
||||
|
||||
--- reload the package
|
||||
|
Reference in New Issue
Block a user