fix: try with uv.spawn powershell.exe for win

ohh windows always so much fun.....
This commit is contained in:
əlemi 2024-09-17 03:46:11 +02:00
parent 81baba98db
commit 646760f3cb
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -31,15 +31,26 @@ local native_path = plugin_dir..sep.."lua"..sep.."codemp"..sep.."new-native."..e
local replace_native_path = plugin_dir..sep.."lua"..sep.."codemp"..sep.."native."..ext local replace_native_path = plugin_dir..sep.."lua"..sep.."codemp"..sep.."native."..ext
local download_url_native = string.format("https://codemp.dev/releases/lua/codemp-lua-%s-%s.%s", arch, platform, ext) local download_url_native = string.format("https://codemp.dev/releases/lua/codemp-lua-%s-%s.%s", arch, platform, ext)
local command = {
Windows_NT = { "Invoke-WebRequest", download_url_native, "-OutFile", native_path },
Linux = {"curl", "-o", native_path, download_url_native },
Mac = {"curl", "-o", native_path, download_url_native },
}
print("downloading codemp native lua extension from '" .. download_url_native .. "' ...") print("downloading codemp native lua extension from '" .. download_url_native .. "' ...")
vim.system(command[os_uname.sysname]):wait() -- TODO can we run this asynchronously? if os_uname.sysname == "Windows_NT" then
local handle, pid = vim.uv.spawn("powershell.exe", {
args = { "-Command", "Invoke-WebRequest "..download_url_native.." -OutFile "..native_path }
})
print("downloading in background... library will be installed upon restart")
else
local res = vim.system({"curl", "-o", native_path, download_url_native }):wait() -- TODO can we run this asynchronously?
print(res.stdout)
print(res.stderr)
print(">> " .. res.code)
if res.code == 0 then
print("downloaded! exit nvim to reload library") print("downloaded! exit nvim to reload library")
else
print("error downloading native library: " .. res.code)
print(res.stdout)
print(res.stderr)
end
end
vim.api.nvim_create_autocmd( vim.api.nvim_create_autocmd(
{"ExitPre"}, {"ExitPre"},