fix(login): make sure to set on all branch (#268)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-27 03:00:18 -04:00 committed by GitHub
parent a8022896a2
commit 64f2c54822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -111,6 +111,7 @@ E.parse_envvar = function(Opts)
local key = nil
vim.g.avante_login = false
if cmd ~= nil then
-- NOTE: in case api_key_name is cmd, and users still set envvar
-- We will try to get envvar first
@ -120,11 +121,11 @@ E.parse_envvar = function(Opts)
---@diagnostic disable: no-unknown
E.cache[Opts._shellenv] = key
E.cache[api_key_name] = key
vim.g.avante_login = true
return key
end
end
vim.g.avante_login = false
local exit_codes = { 0 }
local ok, job_or_err = pcall(
vim.system,

View File

@ -41,9 +41,13 @@ M.get_os_name = function()
end
end
--- This function will run given shell command synchronously.
---@param input_cmd string
---@return integer, string?, string?
M.shell_run = function(input_cmd)
local output = vim.system(vim.split(cmd, " ", { trimempty = true }), { text = true })
local output =
vim.system(vim.split("sh -c " .. vim.fn.shellescape(input_cmd), " ", { trimempty = true }), { text = true }):wait()
return output.code, output.stderr, output.stdout
end
---@alias _ToggleSet fun(state: boolean): nil