aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/platform.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-07-10 16:32:19 +0200
committerGitHub <noreply@github.com>2022-07-10 16:32:19 +0200
commitd1a88ff9cf52feee7ed6893070533955fa022204 (patch)
tree4b6a061e27609f4a0670b27865281e2c60814d5d /lua/mason-core/platform.lua
parentfeat: add luacheck to the registry (#46) (diff)
downloadmason-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/mason-core/platform.lua')
-rw-r--r--lua/mason-core/platform.lua12
1 files changed, 12 insertions, 0 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