Skip to content

Commit

Permalink
fix(require/loadJson): correct path for json files
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Apr 9, 2024
1 parent 10ee931 commit fffdcd9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions imports/require/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`).\
Expand Down

0 comments on commit fffdcd9

Please sign in to comment.