Mercurial > prosody-hg
diff core/moduleapi.lua @ 13719:4309c934e813 13.0
moduleapi: Allow soft dependencies via module:depends(mod, true)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 16 Feb 2025 13:29:07 +0000 |
| parents | a4217361c1c6 |
| children | e6c6f58dfda1 3e6bb6ffbd43 |
line wrap: on
line diff
--- a/core/moduleapi.lua Sun Feb 16 13:19:05 2025 +0000 +++ b/core/moduleapi.lua Sun Feb 16 13:29:07 2025 +0000 @@ -136,10 +136,14 @@ return f(); end -function api:depends(name) +function api:depends(name, soft) local modulemanager = require"prosody.core.modulemanager"; if self:get_option_inherited_set("modules_disabled", {}):contains(name) then - error("Dependency on disabled module mod_"..name); + if not soft then + error("Dependency on disabled module mod_"..name); + end + self:log("debug", "Not loading disabled soft dependency mod_%s", name); + return nil, "disabled"; end if not self.dependencies then self.dependencies = {};
