Skip to content

Commit 0a3189a

Browse files
committed
all: format lua files
1 parent 2ed39f1 commit 0a3189a

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

lua/rest-nvim/utils/init.lua

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,40 @@ end
3030
-- with the env variable value
3131
-- @param str Where replace the placers for the env variables
3232
M.replace_env_vars = function(str)
33-
local env_vars = M.read_env_file()
34-
35-
for var in string.gmatch(str, '{{%w+}}') do
36-
var = var:gsub('{', ''):gsub('}', '')
37-
-- If the env variable wasn't found in the `.env` file then search it
38-
-- in the OS environment variables
39-
if M.has_key(env_vars, var) then
40-
str = str:gsub('{{' .. var .. '}}', env_vars[var])
41-
else
42-
if os.getenv(var) ~= nil then
43-
str = str:gsub('{{' .. var .. '}}', os.getenv(var))
44-
else
45-
error(string.format("Environment variable '%s' was not found.", var))
46-
end
47-
end
48-
end
49-
return str
33+
local env_vars = M.read_env_file()
34+
35+
for var in string.gmatch(str, '{{%w+}}') do
36+
var = var:gsub('{', ''):gsub('}', '')
37+
-- If the env variable wasn't found in the `.env` file then search it
38+
-- in the OS environment variables
39+
if M.has_key(env_vars, var) then
40+
str = str:gsub('{{' .. var .. '}}', env_vars[var])
41+
else
42+
if os.getenv(var) ~= nil then
43+
str = str:gsub('{{' .. var .. '}}', os.getenv(var))
44+
else
45+
error(
46+
string.format(
47+
"Environment variable '%s' was not found.",
48+
var
49+
)
50+
)
51+
end
52+
end
53+
end
54+
return str
5055
end
5156

5257
-- has_key checks if the provided table contains the provided key using a regex
5358
-- @param tbl Table to iterate over
5459
-- @param key The key to be searched in the table
5560
M.has_key = function(tbl, key)
56-
for tbl_key, _ in pairs(tbl) do
57-
if string.find(key, tbl_key) then
58-
return true
59-
end
60-
end
61-
return false
61+
for tbl_key, _ in pairs(tbl) do
62+
if string.find(key, tbl_key) then
63+
return true
64+
end
65+
end
66+
return false
6267
end
6368

6469
-- has_value checks if the provided table contains the provided string using a regex

0 commit comments

Comments
 (0)