Skip to content

Commit

Permalink
fix: avoid calling API functions inside fast event (#892)
Browse files Browse the repository at this point in the history
This won't be a problem once https://github.com/mason-org/mason-registry
is integrated because package installations won't independently execute
code.

Fixes #891.
  • Loading branch information
williamboman authored Jan 12, 2023
1 parent 7344927 commit 4d734ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
16 changes: 9 additions & 7 deletions lua/mason-registry/fourmolu/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ return Pkg.new {
---@async
---@param ctx InstallContext
install = function(ctx)
---@param template string
local function release_file(template_string)
return _.compose(_.format(template_string), _.gsub("^v", ""))
end

github
.download_release_file({
repo = "fourmolu/fourmolu",
out_file = "fourmolu",
asset_file = function(version)
local target = _.coalesce(
_.when(platform.is.mac_x64, "fourmolu-%s-osx-x86_64"),
_.when(platform.is.linux_x64_gnu, "fourmolu-%s-linux-x86_64")
)
return target and target:format(version:gsub("^v", ""))
end,
asset_file = _.coalesce(
_.when(platform.is.mac_x64, release_file "fourmolu-%s-osx-x86_64"),
_.when(platform.is.linux_x64_gnu, release_file "fourmolu-%s-linux-x86_64")
),
})
.with_receipt()
std.chmod("+x", { "fourmolu" })
Expand Down
20 changes: 8 additions & 12 deletions lua/mason-registry/lua-language-server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ return Pkg.new {
github
.unzip_release_file({
repo = "sumneko/vscode-lua",
asset_file = function(version)
local target = coalesce(
when(platform.is.mac_x64, "vscode-lua-%s-darwin-x64.vsix"),
when(platform.is.mac_arm64, "vscode-lua-%s-darwin-arm64.vsix"),
when(platform.is.linux_x64_gnu, "vscode-lua-%s-linux-x64.vsix"),
when(platform.is.linux_arm64_gnu, "vscode-lua-%s-linux-arm64.vsix"),
when(platform.is.win_x64, "vscode-lua-%s-win32-x64.vsix"),
when(platform.is.win_x86, "vscode-lua-%s-win32-ia32.vsix")
)

return target and target:format(version)
end,
asset_file = coalesce(
when(platform.is.mac_x64, _.format "vscode-lua-%s-darwin-x64.vsix"),
when(platform.is.mac_arm64, _.format "vscode-lua-%s-darwin-arm64.vsix"),
when(platform.is.linux_x64_gnu, _.format "vscode-lua-%s-linux-x64.vsix"),
when(platform.is.linux_arm64_gnu, _.format "vscode-lua-%s-linux-arm64.vsix"),
when(platform.is.win_x64, _.format "vscode-lua-%s-win32-x64.vsix"),
when(platform.is.win_x86, _.format "vscode-lua-%s-win32-ia32.vsix")
),
})
.with_receipt()

Expand Down

0 comments on commit 4d734ae

Please sign in to comment.