Software /
code /
prosody
Comparison
util/startup.lua @ 10199:72afd4ed8ac9
util.startup: Now calls a function to complement lua's path/cpath
author | João Duarte <jvsDuarte08@gmail.com> |
---|---|
date | Thu, 01 Aug 2019 09:22:50 -0700 |
parent | 10196:5e1012f2f2b7 |
child | 10201:2457b6b1908b |
comparison
equal
deleted
inserted
replaced
10198:83541f0ff14f | 10199:72afd4ed8ac9 |
---|---|
227 | 227 |
228 function startup.setup_plugindir() | 228 function startup.setup_plugindir() |
229 local custom_plugin_paths = config.get("*", "plugin_paths"); | 229 local custom_plugin_paths = config.get("*", "plugin_paths"); |
230 local installer_plugin_path = config.get("*", "installer_plugin_path") or "custom_plugins"; | 230 local installer_plugin_path = config.get("*", "installer_plugin_path") or "custom_plugins"; |
231 local path_sep = package.config:sub(3,3); | 231 local path_sep = package.config:sub(3,3); |
232 local dir_sep = package.config:sub(1,1); | |
233 if custom_plugin_paths then | 232 if custom_plugin_paths then |
234 -- path1;path2;path3;defaultpath... | 233 -- path1;path2;path3;defaultpath... |
235 -- luacheck: ignore 111 | 234 -- luacheck: ignore 111 |
236 CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); | 235 CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); |
237 prosody.paths.plugins = CFG_PLUGINDIR; | 236 prosody.paths.plugins = CFG_PLUGINDIR; |
238 end | 237 end |
239 installer_plugin_path = config.resolve_relative_path(require "lfs".currentdir(), installer_plugin_path); | 238 installer_plugin_path = config.resolve_relative_path(require "lfs".currentdir(), installer_plugin_path); |
240 require "lfs".mkdir(installer_plugin_path) | 239 require "lfs".mkdir(installer_plugin_path); |
241 -- Checking for duplicates | 240 config.complement_lua_path(installer_plugin_path); |
242 -- The commands using luarocks need the path to the directory that has the /share and /lib folders. | |
243 local lua_version = _VERSION:match(" (.+)$") | |
244 local sub_path = dir_sep.."lua"..dir_sep..lua_version..dir_sep | |
245 if not string.match(package.path, installer_plugin_path) then | |
246 package.path = package.path..path_sep..installer_plugin_path..dir_sep.."share"..sub_path.."?.lua"; | |
247 package.path = package.path..path_sep..installer_plugin_path..dir_sep.."share"..sub_path.."?"..dir_sep.."init.lua"; | |
248 end | |
249 if not string.match(package.path, installer_plugin_path) then | |
250 package.cpath = package.cpath..path_sep..installer_plugin_path..dir_sep.."lib"..sub_path.."?.lua"; | |
251 end | |
252 CFG_PLUGINDIR = installer_plugin_path..path_sep..(CFG_PLUGINDIR or "plugins"); | 241 CFG_PLUGINDIR = installer_plugin_path..path_sep..(CFG_PLUGINDIR or "plugins"); |
253 prosody.paths.plugins = CFG_PLUGINDIR; | 242 prosody.paths.plugins = CFG_PLUGINDIR; |
254 end | 243 end |
255 | 244 |
256 function startup.chdir() | 245 function startup.chdir() |