summaryrefslogtreecommitdiff
path: root/server/src/matcher/find_lib.lua
blob: 92d90e500dc4c48f4fa32038b7c428f6dd885d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local lni = require 'lni'

local Libs
local function getLibs()
    if Libs then
        return Libs
    end
    Libs = {}
    for path in io.scan(ROOT / 'libs') do
        local buf = io.load(path)
        if buf then
            xpcall(lni.classics, log.error, buf, path:string(), {Libs})
        end
    end
    return Libs
end

return function (var)
    local key = var.key
    local libs = getLibs()
    return libs[key]
end