Skip to content

Commit

Permalink
feat(pkg): utils to get rock to url mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 25, 2024
1 parent 25981e1 commit be74a8a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lua/lazy/community/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ local M = {}
---@type table<string, string>
local mapping = nil

local function _load()
if mapping then
return
end
mapping = {}
---@type {name:string, url:string, version:string}[]
local gen = require("lazy.community._generated")
for _, rock in ipairs(gen) do
mapping[rock.name] = rock.url
local function load()
if not mapping then
mapping = {}
---@type {name:string, url:string, version:string}[]
local gen = require("lazy.community._generated")
for _, rock in ipairs(gen) do
mapping[rock.name] = rock.url
end
end
return mapping
end

---@param rock string
---@return string?
function M.get_url(rock)
_load()
return mapping[rock]
return load()[rock]
end

return M

0 comments on commit be74a8a

Please sign in to comment.