diff options
| author | William Boman <william@redwill.se> | 2022-05-13 17:36:49 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2022-05-13 17:38:17 +0200 |
| commit | c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896 (patch) | |
| tree | 46111dff860189c822ae22bb3b6f547259a061ab /lua/nvim-lsp-installer/core/managers/github | |
| parent | ui: reset outdated server flag after any kind of server install/uninstall int... (diff) | |
| download | mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar.gz mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar.bz2 mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar.lz mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar.xz mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.tar.zst mason-c4ed66fc632a0a9bdac705d60f71c7d9a3bbd896.zip | |
feat(github): add `include_prerelease` option to `fetch_latest_release`
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers/github')
| -rw-r--r-- | lua/nvim-lsp-installer/core/managers/github/client.lua | 9 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/core/managers/github/init.lua | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/github/client.lua b/lua/nvim-lsp-installer/core/managers/github/client.lua index e2d6e977..da0e4302 100644 --- a/lua/nvim-lsp-installer/core/managers/github/client.lua +++ b/lua/nvim-lsp-installer/core/managers/github/client.lua @@ -45,14 +45,17 @@ function M.fetch_release(repo, tag_name) end) end ----@alias FetchLatestGithubReleaseOpts {tag_name_pattern:string} +---@alias FetchLatestGithubReleaseOpts {tag_name_pattern:string|nil, include_prelease: boolean} ---@async ---@param repo string @The GitHub repo ("username/repo"). ---@param opts FetchLatestGithubReleaseOpts|nil ---@return Result @of GitHubRelease function M.fetch_latest_release(repo, opts) - opts = opts or {} + opts = opts or { + tag_name_pattern = nil, + include_prelease = false, + } return M.fetch_releases(repo):map_catching( ---@param releases GitHubRelease[] function(releases) @@ -60,7 +63,7 @@ function M.fetch_latest_release(repo, opts) local latest_release = list_find_first( ---@param release GitHubRelease function(release) - local is_stable_release = not release.prerelease and not release.draft + local is_stable_release = (release.prerelease and opts.include_prelease) and not release.draft if opts.tag_name_pattern then return is_stable_release and release.tag_name:match(opts.tag_name_pattern) end diff --git a/lua/nvim-lsp-installer/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua index 87947447..58856b66 100644 --- a/lua/nvim-lsp-installer/core/managers/github/init.lua +++ b/lua/nvim-lsp-installer/core/managers/github/init.lua @@ -42,8 +42,9 @@ function M.release_file(opts) if not asset_file then error( ( - "Could not find which release file to download. Most likely the current operating system, architecture (%s), or libc (%s) is not supported." - ):format(platform.arch, platform.get_libc()) + "Could not find which release file to download.\nMost likely the current operating system, architecture (%s), or libc (%s) is not supported." + ):format(platform.arch, platform.get_libc()), + 0 ) end local download_url = ("https://github.com/%s/releases/download/%s/%s"):format(opts.repo, release, asset_file) |
