Changeset

6718:be98ebe87eef

configmanager: Refactor function to avoid re-declaring local variable [luacheck]
author Matthew Wild <mwild1@gmail.com>
date Mon, 18 May 2015 19:07:31 +0100
parents 6717:4fecfc81dac1
children 6719:0ef7a8c8fe8c
files core/configmanager.lua
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/core/configmanager.lua	Mon May 18 19:07:06 2015 +0100
+++ b/core/configmanager.lua	Mon May 18 19:07:31 2015 +0100
@@ -183,6 +183,7 @@
 		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 @@
 						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;