diff options
| author | William Boman <william@redwill.se> | 2022-07-06 19:41:43 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2022-07-07 00:39:59 +0200 |
| commit | 5f634e0c37e723fc0c33e06b4fd5c2180178db40 (patch) | |
| tree | fa4f09363adefa8259e23e4d1ea036db628b1243 /lua/nvim-lsp-installer/core/fetch.lua | |
| parent | feat(health): use stderr for java version, also check for JAVA_HOME (#765) (diff) | |
| download | mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.gz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.bz2 mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.lz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.xz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.zst mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.zip | |
mason.nvim
Diffstat (limited to 'lua/nvim-lsp-installer/core/fetch.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/core/fetch.lua | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/lua/nvim-lsp-installer/core/fetch.lua b/lua/nvim-lsp-installer/core/fetch.lua deleted file mode 100644 index 4a5ff4df..00000000 --- a/lua/nvim-lsp-installer/core/fetch.lua +++ /dev/null @@ -1,54 +0,0 @@ -local log = require "nvim-lsp-installer.log" -local platform = require "nvim-lsp-installer.core.platform" -local Result = require "nvim-lsp-installer.core.result" -local spawn = require "nvim-lsp-installer.core.spawn" -local powershell = require "nvim-lsp-installer.core.managers.powershell" - -local USER_AGENT = "nvim-lsp-installer (+https://github.com/williamboman/nvim-lsp-installer)" - -local HEADERS = { - wget = { "--header", ("User-Agent: %s"):format(USER_AGENT) }, - curl = { "-H", ("User-Agent: %s"):format(USER_AGENT) }, - iwr = ("-Headers @{'User-Agent' = '%s'}"):format(USER_AGENT), -} - ----@alias FetchOpts {out_file:string} - ----@async ----@param url string @The url to fetch. ----@param opts FetchOpts -local function fetch(url, opts) - opts = opts or {} - log.fmt_debug("Fetching URL %s", url) - - local platform_specific = Result.failure() - - if platform.is_win then - if opts.out_file then - platform_specific = powershell.command( - ([[iwr %s -UseBasicParsing -Uri %q -OutFile %q;]]):format(HEADERS.iwr, url, opts.out_file) - ) - else - platform_specific = powershell.command( - ([[Write-Output (iwr %s -UseBasicParsing -Uri %q).Content;]]):format(HEADERS.iwr, url) - ) - end - end - - return platform_specific - :recover_catching(function() - return spawn.wget({ HEADERS.wget, "-nv", "-O", opts.out_file or "-", url }):get_or_throw() - end) - :recover_catching(function() - return spawn.curl({ HEADERS.curl, "-fsSL", opts.out_file and { "-o", opts.out_file } or vim.NIL, url }):get_or_throw() - end) - :map(function(result) - if opts.out_file then - return result - else - return result.stdout - end - end) -end - -return fetch |
