Conversation
Refactor the IncludeDir function to improve clarity and structure.
Removed undo functionality for container creation.
There was a problem hiding this comment.
Pull request overview
This PR adds optional recursive directory inclusion functionality to the ix.util.IncludeDir function, allowing developers to optionally include Lua files from subdirectories when loading plugins or schemas.
Key changes:
- Added
bRecursiveas a third optional parameter to control recursive subdirectory traversal - Modified file.Find to return both files and directories by changing the pattern from
/*.luato/* - Added explicit
.luafile extension filtering usingstring.EndsWith
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gamemode/core/sh_util.lua
Outdated
| for _, d in ipairs(dirs) do | ||
| ix.util.IncludeDir(directory.."/"..d, bFromLua, bRecursive) | ||
| end |
There was a problem hiding this comment.
The 'dirs' variable returned from file.Find may be nil if no directories are found. Attempting to iterate over nil with ipairs will cause a runtime error. The dirs variable should be checked for nil or defaulted to an empty table before iteration.
gamemode/core/sh_util.lua
Outdated
| for _, v in ipairs(files) do | ||
| if (string.EndsWith(v, ".lua")) then | ||
| ix.util.Include(directory.."/"..v) | ||
| end | ||
| end |
There was a problem hiding this comment.
The 'files' variable returned from file.Find may be nil if no files are found. Attempting to iterate over nil with ipairs will cause a runtime error. The files variable should be checked for nil or defaulted to an empty table before iteration.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
feat(util): add optional recursive parameter to IncludeDir
Add bRecursive parameter to ix.util.IncludeDir to allow optional
recursive inclusion of subdirectories. When false, only files in
the specified directory are included, without traversing subdirectories.