From fffdcd99997caa7691b576aff7f95c241b7d7f77 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:02:35 +1000 Subject: [PATCH] fix(require/loadJson): correct path for json files --- imports/require/shared.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/require/shared.lua b/imports/require/shared.lua index 5b964645c..54373d328 100644 --- a/imports/require/shared.lua +++ b/imports/require/shared.lua @@ -121,7 +121,7 @@ function lib.load(filePath, env) if result then return result() end - error(err) + error(("file '%s' not found\n\t%s"):format(filePath, err)) end ---@param filePath string @@ -132,14 +132,14 @@ function lib.loadJson(filePath) error(("file path must be a string (received '%s')"):format(filePath), 2) end - local resourceSrc, modPath = getModuleInfo(filePath) + local resourceSrc, modPath = getModuleInfo(filePath:gsub('%.', '/')) local resourceFile = LoadResourceFile(resourceSrc, ('%s.json'):format(modPath)) if resourceFile then return json.decode(resourceFile) end - error(('cannot load json file at path %s'):format(modPath)) + error(("json file '%s' not found\n\tno file '@%s/%s.json'"):format(filePath, resourceSrc, modPath)) end ---Loads the given module, returns any value returned by the seacher (`true` when `nil`).\