prefix file path with @ when loading string

This commit is contained in:
leaf corcoran 2014-06-06 14:36:03 -07:00
parent f10ec9d8ad
commit c73762e00e
2 changed files with 4 additions and 4 deletions

View File

@ -60,7 +60,7 @@ moon_loader = function(name)
if file then
local text = file:read("*a")
file:close()
local res, err = loadstring(text, file_path)
local res, err = loadstring(text, "@" .. tostring(file_path))
if not res then
error(file_path .. ": " .. err)
end
@ -90,7 +90,7 @@ loadfile = function(fname, ...)
end
local text = assert(file:read("*a"))
file:close()
return loadstring(text, fname, ...)
return loadstring(text, "@" .. tostring(fname), ...)
end
dofile = function(...)
local f = assert(loadfile(...))

View File

@ -46,7 +46,7 @@ moon_loader = (name) ->
if file
text = file\read "*a"
file\close!
res, err = loadstring text, file_path
res, err = loadstring text, "@#{file_path}"
if not res
error file_path .. ": " .. err
@ -72,7 +72,7 @@ loadfile = (fname, ...) ->
return nil, err unless file
text = assert file\read "*a"
file\close!
loadstring text, fname, ...
loadstring text, "@#{fname}", ...
-- throws errros
dofile = (...) ->