aboutsummaryrefslogtreecommitdiffstats
path: root/loader.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-03-17 13:51:43 +0100
committerKim Alvefur <zash@zash.se>2023-03-17 13:51:43 +0100
commitd33f55156bc3db2f545e9262b32de86ff05b77ae (patch)
tree9e03bc843b60aa1fdd588d070c7783a7c84856d2 /loader.lua
parent9dd7ce434d2297ab807639722b3416600e1180cf (diff)
downloadprosody-d33f55156bc3db2f545e9262b32de86ff05b77ae.tar.gz
prosody-d33f55156bc3db2f545e9262b32de86ff05b77ae.zip
prosody.loader: Allow loading modules under 'prosody' namespace (#1223)
Actually `hg mv`-ing all the files is disruptive, basically breaking everything from rebasing all my WIP draft commits to the package building. So instead, what if we didn't and instead rewrote package names as they are `require()`-d? Debian packages produced by the Prosody are already installed into this structure so much will Just Work if all require calls are updated.
Diffstat (limited to 'loader.lua')
-rw-r--r--loader.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/loader.lua b/loader.lua
new file mode 100644
index 00000000..e6931cce
--- /dev/null
+++ b/loader.lua
@@ -0,0 +1,9 @@
+for i = #package.searchers, 1, -1 do
+ local search = package.searchers[i];
+ table.insert(package.searchers, i, function(module_name)
+ local lib = module_name:match("^prosody%.(.*)$");
+ if lib then
+ return search(lib);
+ end
+ end)
+end