Skip to content

Commit

Permalink
fix: ensure no duplicate languages with different casing (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman authored Jul 22, 2022
1 parent 1e3c60c commit 8d7dd71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/mason-registry/prettier/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ return Pkg.new {
Pkg.Lang.JSON,
Pkg.Lang.CSS,
Pkg.Lang.SCSS,
Pkg.Lang.Less,
Pkg.Lang.LESS,
Pkg.Lang.HTML,
Pkg.Lang.Vue,
Pkg.Lang.Angular,
Expand Down
10 changes: 10 additions & 0 deletions scripts/lua/mason-scripts/mason/generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ local MASON_REGISTRY_DIR = path.concat { vim.loop.cwd(), "lua", "mason-registry"
---@async
local function create_language_map()
print "Creating language map…"
local indexed_languages = {}
local language_map = {}
local sorted_packages = _.sort_by(_.prop "name", registry.get_all_packages())
_.each(function(pkg)
_.each(function(language)
local language_lc = language:lower()
if indexed_languages[language_lc] and indexed_languages[language_lc] ~= language then
error(
("Found two variants of same language with differing cases %s != %s"):format(
indexed_languages[language_lc],
language
)
)
end
indexed_languages[language_lc] = language
language_map[language_lc] = _.append(pkg.name, language_map[language_lc] or {})
end, pkg.spec.languages)
end, sorted_packages)
Expand Down

0 comments on commit 8d7dd71

Please sign in to comment.