aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/chrome-debug-adapter/init.lua
blob: 29085399c5fced279421ca05b80186bac6a0010e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local Pkg = require "mason.core.package"
local github = require "mason.core.managers.github"
local git = require "mason.core.managers.git"
local _ = require "mason.core.functional"
local path = require "mason.core.path"
local Optional = require "mason.core.optional"

return Pkg.new {
    name = "chrome-debug-adapter",
    desc = [[Debug your JavaScript code running in Google Chrome.]],
    homepage = "https://github.com/Microsoft/vscode-chrome-debug",
    languages = { Pkg.Lang.JavaScript, Pkg.Lang.TypeScript },
    categories = { Pkg.Cat.DAP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local source = github.tag { repo = "Microsoft/vscode-chrome-debug" }
        source.with_receipt()
        git.clone { "https://github.com/Microsoft/vscode-chrome-debug", version = Optional.of(source.tag) }
        ctx.spawn.npm { "install" }
        ctx.spawn.npm { "run", "build" }
        pcall(function()
            -- this errors for some reason - but it effectively reduces the node_modules/ size by ~98%
            ctx.spawn.npm { "install", "--production" }
        end)
        -- vscode-chrome-debug comes with a lot of extra baggage
        ctx.fs:rmrf "images"
        ctx.fs:rmrf "testdata"
        ctx.fs:rmrf ".git"
        ctx:link_bin(
            "chrome-debug-adapter",
            ctx:write_node_exec_wrapper("chrome-debug-adapter", path.concat { "out", "src", "chromeDebug.js" })
        )
    end,
}