fix(require): chunk name and error path for load/loadjson

This commit is contained in:
Linden
2023-12-19 09:04:29 +11:00
parent 8a5232c056
commit 0c2f0ec68e

View File

@@ -66,9 +66,8 @@ function lib.load(filePath, env)
local resourceFile = LoadResourceFile(resourceSrc, scriptPath) local resourceFile = LoadResourceFile(resourceSrc, scriptPath)
if resourceFile then if resourceFile then
filePath = ('@@%s/%s'):format(resourceSrc, filePath)
local chunk, err = load(resourceFile, filePath, 't', env or _ENV) local chunk, err = load(resourceFile, ('@@%s/%s'):format(resourceSrc, modpath), 't', env or _ENV)
if not chunk or err then if not chunk or err then
error(err or 'an unknown error occurred', 2) error(err or 'an unknown error occurred', 2)
@@ -78,7 +77,7 @@ function lib.load(filePath, env)
end end
end end
error(('cannot load file at path %s'):format(filePath)) error(('cannot load file at path %s'):format(modpath))
end end
---@param filePath string ---@param filePath string
@@ -104,7 +103,7 @@ function lib.loadJson(filePath)
return json.decode(resourceFile) return json.decode(resourceFile)
end end
error(('cannot load json file at path %s'):format(filePath)) error(('cannot load json file at path %s'):format(modpath))
end end
---Loads the given module inside the current resource, returning any values returned by the file or `true` when `nil`. ---Loads the given module inside the current resource, returning any values returned by the file or `true` when `nil`.