refactor(wezterm): remove determine_home_path

This commit is contained in:
Price Hiller 2022-07-29 16:29:04 -05:00
parent af9253cbc1
commit f12eceaa7b

View File

@ -35,40 +35,6 @@ function M.Table.merge(...)
return ret
end
--- Returns the path to the users home, note this string needs to be regularized as
--- this is used on both windows and unix.
--- @return string
function M.determine_home_path()
-- This helps give a better error message
-- if we are unable to find their home dir
-- from a environment variable
local checked_env_vars = {}
-- Attempt to get UNIX home
local unix_home_var = "HOME"
local unix_home = os.getenv(unix_home_var)
table.insert(checked_env_vars, unix_home_var)
-- This style is chosen as a guard so it's easier
-- to extend in the future
if unix_home then
return unix_home
end
-- Attempt to get Windows home
local win_home_drive = os.getenv("HOMEDRIVE")
local win_home = os.getenv("HOMEPATH")
if win_home and win_home_drive then
return win_home_drive .. win_home
end
-- NOTE: This will error if it cannot determine the home path
error(
"Unable to determine user's home directory, checked environment variables:\n\n"
.. M.Table.dump(checked_env_vars)
.. "\n\n"
)
end
--- Return a table with `name` representing the OS name and `arch` representing
--- the architecture.
---