diff options
| author | William Boman <william@redwill.se> | 2022-07-10 16:32:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-10 16:32:19 +0200 |
| commit | d1a88ff9cf52feee7ed6893070533955fa022204 (patch) | |
| tree | 4b6a061e27609f4a0670b27865281e2c60814d5d /lua | |
| parent | feat: add luacheck to the registry (#46) (diff) | |
| download | mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar.gz mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar.bz2 mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar.lz mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar.xz mason-d1a88ff9cf52feee7ed6893070533955fa022204.tar.zst mason-d1a88ff9cf52feee7ed6893070533955fa022204.zip | |
fix(node-debug2-adapter): fix build on Node >= 18 (#47)
Fixes #41.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/platform.lua | 12 | ||||
| -rw-r--r-- | lua/mason-registry/node-debug2-adapter/init.lua | 15 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lua/mason-core/platform.lua b/lua/mason-core/platform.lua index 64e6ba52..7ae51a67 100644 --- a/lua/mason-core/platform.lua +++ b/lua/mason-core/platform.lua @@ -156,4 +156,16 @@ M.is = setmetatable({}, { end, }) +---@async +function M.get_node_version() + local spawn = require "mason-core.spawn" + local _ = require "mason-core.functional" + + return spawn.node({ "--version" }):map(function(result) + -- Parses output such as "v16.3.1" into major, minor, patch + local _, _, major, minor, patch = _.head(_.split("\n", result.stdout)):find "v(%d+)%.(%d+)%.(%d+)" + return { tonumber(major), tonumber(minor), tonumber(patch) } + end) +end + return M diff --git a/lua/mason-registry/node-debug2-adapter/init.lua b/lua/mason-registry/node-debug2-adapter/init.lua index 76b24a6d..33ff2790 100644 --- a/lua/mason-registry/node-debug2-adapter/init.lua +++ b/lua/mason-registry/node-debug2-adapter/init.lua @@ -4,6 +4,7 @@ local git = require "mason-core.managers.git" local _ = require "mason-core.functional" local path = require "mason-core.path" local Optional = require "mason-core.optional" +local platform = require "mason-core.platform" return Pkg.new { name = "node-debug2-adapter", @@ -18,7 +19,19 @@ return Pkg.new { source.with_receipt() git.clone { "https://github.com/microsoft/vscode-node-debug2", version = Optional.of(source.tag) } ctx.spawn.npm { "install" } - ctx.spawn.npm { "run", "build" } + local node_env = platform + .get_node_version() + :map(function(version) + if version[1] >= 18 then + return { + NODE_OPTIONS = "--no-experimental-fetch", + } + else + return {} + end + end) + :get_or_else {} + ctx.spawn.npm { "run", "build", env = node_env } ctx.spawn.npm { "install", "--production" } ctx:link_bin( "node-debug2-adapter", |
