From 940870318d1225ed3106355f48fac13f0d21d35c Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Mon, 17 Oct 2022 20:17:54 +0100 Subject: [PATCH] Fix bug where loading namespaces using folder/init.lua entries would only work if "folder" was 3 characters --- concord/utils.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/concord/utils.lua b/concord/utils.lua index da83c4d..92e19aa 100644 --- a/concord/utils.lua +++ b/concord/utils.lua @@ -34,11 +34,18 @@ function Utils.loadNamespace(pathOrFiles, namespace) local files = love.filesystem.getDirectoryItems(pathOrFiles) for _, file in ipairs(files) do - local name = file:sub(1, #file - 4) - local path = pathOrFiles.."."..name + local isFile = love.filesystem.getInfo(pathOrFiles .. "/" .. file).type == "file" - local value = require(path) - if namespace then namespace[name] = value end + if isFile then + local name = file:sub(1, #file - 4) + local path = pathOrFiles.."."..name + + local value = require(path) + if namespace then namespace[name] = value end + else + local value = require(pathOrFiles.."."..file) + if namespace then namespace[file] = value end + end end elseif (type(pathOrFiles == "table")) then for _, path in ipairs(pathOrFiles) do @@ -61,4 +68,4 @@ function Utils.loadNamespace(pathOrFiles, namespace) return namespace end -return Utils \ No newline at end of file +return Utils