mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 20:33:54 -04:00
Merge pull request #66 from wolfboyft/master
Fix bug where loading namespaces using folder/init.lua entries would only work if "folder" was 3 characters
This commit is contained in:
commit
a45d89457b
1 changed files with 12 additions and 5 deletions
|
@ -34,11 +34,18 @@ function Utils.loadNamespace(pathOrFiles, namespace)
|
||||||
local files = love.filesystem.getDirectoryItems(pathOrFiles)
|
local files = love.filesystem.getDirectoryItems(pathOrFiles)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local name = file:sub(1, #file - 4)
|
local isFile = love.filesystem.getInfo(pathOrFiles .. "/" .. file).type == "file"
|
||||||
local path = pathOrFiles.."."..name
|
|
||||||
|
|
||||||
local value = require(path)
|
if isFile then
|
||||||
if namespace then namespace[name] = value end
|
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
|
end
|
||||||
elseif (type(pathOrFiles == "table")) then
|
elseif (type(pathOrFiles == "table")) then
|
||||||
for _, path in ipairs(pathOrFiles) do
|
for _, path in ipairs(pathOrFiles) do
|
||||||
|
@ -61,4 +68,4 @@ function Utils.loadNamespace(pathOrFiles, namespace)
|
||||||
return namespace
|
return namespace
|
||||||
end
|
end
|
||||||
|
|
||||||
return Utils
|
return Utils
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue