Skip to content

Commit

Permalink
fix(spectral-language-server): build directly from source (#464)
Browse files Browse the repository at this point in the history
The npm package is an unofficial one, and it seems to be relying on a
build script (broken) to execute during installation, instead of pre-packaging
it.

Fixes #463.
  • Loading branch information
williamboman committed Sep 26, 2022
1 parent 82b45c4 commit e0268a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion lua/mason-core/managers/github/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ local M = {}
---@param asset_file string
---@param release string
local function with_release_file_receipt(repo, asset_file, release)
---@return InstallReceiptGitHubReleaseFileSource
return function()
local ctx = installer.context()
ctx.receipt:with_primary_source {
Expand Down
21 changes: 19 additions & 2 deletions lua/mason-registry/spectral-language-server/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local Pkg = require "mason-core.package"
local npm = require "mason-core.managers.npm"
local git = require "mason-core.managers.git"
local github = require "mason-core.managers.github"
local _ = require "mason-core.functional"
local Optional = require "mason-core.optional"
local path = require "mason-core.path"

return Pkg.new {
name = "spectral-language-server",
Expand All @@ -11,5 +14,19 @@ return Pkg.new {
homepage = "https://github.com/luizcorreia/spectral-language-server",
languages = { Pkg.Lang.JSON, Pkg.Lang.YAML },
categories = { Pkg.Cat.LSP },
install = npm.packages { "spectral-language-server", bin = { "spectral-language-server" } },
---@async
---@param ctx InstallContext
install = function(ctx)
local source = github.tag { repo = "stoplightio/vscode-spectral" }
source.with_receipt()
ctx.fs:mkdir "build"
ctx:chdir("build", function()
git.clone { "https://github.com/stoplightio/vscode-spectral", version = Optional.of(source.tag) }
ctx.spawn.npm { "install" }
ctx.spawn.node { "make", "package" }
end)
ctx.fs:rename(path.concat { "build", "dist", "server", "index.js" }, "spectral-language-server.js")
ctx.fs:rmrf "build"
ctx:write_node_exec_wrapper("spectral-language-server", "spectral-language-server.js")
end,
}

0 comments on commit e0268a6

Please sign in to comment.