Ignore non-lua files in Utils.loadNamespace

Fixes #48
This commit is contained in:
Pablo Ariel Mayobre 2021-08-09 22:09:41 -03:00 committed by GitHub
parent 6379092642
commit d6bd0de564
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
return Utils