Skip to content

Commit

Permalink
#462 use required name instead of full path
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Mar 27, 2021
1 parent 3ee51ba commit 2e78c01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions platform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ else
package.path = rootPath .. script .. '/?.lua'
.. ';' .. rootPath .. script .. '/?/init.lua'
end

package.searchers[2] = function (name)
local filename, err = package.searchpath(name, package.path)
if not filename then
return err
end
local f = io.open(filename)
local buf = f:read '*a'
f:close()
local init, err = load(buf, '@' .. name)
if not init then
return err
end
return init, filename
end
6 changes: 3 additions & 3 deletions script/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ m.size = 0
m.maxSize = 100 * 1024 * 1024

local function trimSrc(src)
src = src:sub(m.prefixLen + 3, -5)
src = src:gsub('^[/\\]+', '')
src = src:gsub('[\\/]+', '.')
if src:sub(1, 1) == '@' then
src = src:sub(2)
end
return src
end

Expand Down

0 comments on commit 2e78c01

Please sign in to comment.