From be74a8a535fea6a480143fb52b4d6958d9e2da94 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 25 Jun 2024 20:38:50 +0200 Subject: [PATCH] feat(pkg): utils to get rock to url mappings --- lua/lazy/community/init.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lua/lazy/community/init.lua b/lua/lazy/community/init.lua index 4e762ec..1cd20e8 100644 --- a/lua/lazy/community/init.lua +++ b/lua/lazy/community/init.lua @@ -3,23 +3,22 @@ local M = {} ---@type table 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