From d6bd0de5649f107680cb1cc67835d259e10f4e2c Mon Sep 17 00:00:00 2001 From: Pablo Ariel Mayobre Date: Mon, 9 Aug 2021 22:09:41 -0300 Subject: [PATCH] Ignore non-lua files in Utils.loadNamespace Fixes #48 --- concord/utils.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/concord/utils.lua b/concord/utils.lua index d1d333a..b3152b4 100644 --- a/concord/utils.lua +++ b/concord/utils.lua @@ -38,11 +38,13 @@ 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 + if string.match(file, '%.lua$') ~= nil then + local name = file:sub(1, #file - 4) + local path = pathOrFiles.."."..name - local value = require(path) - if namespace then namespace[name] = value end + local value = require(path) + if namespace then namespace[name] = value end + end end elseif type(pathOrFiles) == "table" then for _, path in ipairs(pathOrFiles) do @@ -65,4 +67,4 @@ function Utils.loadNamespace(pathOrFiles, namespace) return namespace end -return Utils \ No newline at end of file +return Utils