aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-05-18 19:07:31 +0100
committerMatthew Wild <mwild1@gmail.com>2015-05-18 19:07:31 +0100
commitf96b8f343a63b71078fe6f42496484f8a5d5fb33 (patch)
tree7eb54d4ac2541d9362536bc37a23d828173ff77d /core
parent3de0d3e0496ecfac8c6fa3f85596646124a87343 (diff)
downloadprosody-f96b8f343a63b71078fe6f42496484f8a5d5fb33.tar.gz
prosody-f96b8f343a63b71078fe6f42496484f8a5d5fb33.zip
configmanager: Refactor function to avoid re-declaring local variable [luacheck]
Diffstat (limited to 'core')
-rw-r--r--core/configmanager.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index a85f950c..5ee131ad 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -183,6 +183,7 @@ do
env.component = env.Component;
function env.Include(file)
+ -- Check whether this is a wildcard Include
if file:match("[*?]") then
local lfs = deps.softreq "lfs";
if not lfs then
@@ -202,16 +203,17 @@ do
env.Include(path..path_sep..f);
end
end
- else
- local file = resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file);
- local f, err = io.open(file);
- if f then
- local ret, err = parsers.lua.load(f:read("*a"), file, config);
- if not ret then error(err:gsub("%[string.-%]", file), 0); end
- end
- if not f then error("Error loading included "..file..": "..err, 0); end
- return f, err;
+ return;
+ end
+ -- Not a wildcard, so resolve (potentially) relative path and run through config parser
+ file = resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file);
+ local f, err = io.open(file);
+ if f then
+ local ret, err = parsers.lua.load(f:read("*a"), file, config_table);
+ if not ret then error(err:gsub("%[string.-%]", file), 0); end
end
+ if not f then error("Error loading included "..file..": "..err, 0); end
+ return f, err;
end
env.include = env.Include;