Skip to content

Commit

Permalink
fix(env): dotenv with = in value should work now
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Jul 10, 2024
1 parent 6b1f35f commit 9d59626
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kulala.nvim <small>1.6.0</small>
# kulala.nvim <small>1.6.1</small>

> A minimal 🤏 HTTP-client 🐼 interface 🖥️ for Neovim ❤️.
Expand Down
2 changes: 1 addition & 1 deletion lua/kulala/globals/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local FS = require("kulala.utils.fs")

local M = {}

M.VERSION = "1.6.0"
M.VERSION = "1.6.1"
M.UI_ID = "kulala://ui"
M.HEADERS_FILE = FS.get_plugin_tmp_dir() .. "/headers.txt"
M.BODY_FILE = FS.get_plugin_tmp_dir() .. "/body.txt"
Expand Down
7 changes: 4 additions & 3 deletions lua/kulala/parser/env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ M.get_env = function()
local selected_env = f[selected_env_name]
if selected_env then
env = vim.tbl_extend('force', env, selected_env)
else
vim.notify('Selected environment ('.. selected_env_name ..') not found in http-client.env.json', vim.log.levels.ERROR)
end
elseif dotenv then
local dotenv_env = vim.fn.readfile(dotenv)
for _, line in ipairs(dotenv_env) do
local key, value = line:match('([^=]+)=(.*)')
if line:match('^%s*$') or line:match('^%s*#') then
return
end
local key, value = line:match('^%s*([^=]+)%s*=%s*(.*)%s*$')
if key and value then
env[key] = value
end
Expand Down
10 changes: 1 addition & 9 deletions lua/kulala/parser/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ local function parse_variables(node, tree, text, variables)
local variable = variables[variable_name]
-- If the variable was not found in the document then fallback to the shell environment
if not variable then
---@diagnostic disable-next-line need-check-nil
vim.notify(
"The variable '" .. variable_name .. "' was not found in the document, falling back to the environment ..."
)
local env_var = env[variable_name]
if not env_var then
---@diagnostic disable-next-line need-check-nil
Expand Down Expand Up @@ -274,10 +270,6 @@ local function traverse_body(tbl, variables)
local variable = vars[variable_name]
-- If the variable was not found in the document then fallback to the shell environment
if not variable then
---@diagnostic disable-next-line need-check-nil
vim.notify(
"The variable '" .. variable_name .. "' was not found in the document, falling back to the environment ..."
)
local env_var = env[variable_name]
if not env_var then
---@diagnostic disable-next-line need-check-nil
Expand Down Expand Up @@ -436,7 +428,7 @@ function M.parse()
table.insert(res.cmd, res.body)
elseif res.body.__TYPE == "json" then
res.body.__TYPE = nil
table.insert(res.cmd, "--data-raw")
table.insert(res.cmd, "--data")
table.insert(res.cmd, vim.json.encode(res.body))
elseif res.body.__TYPE == "form" then
res.body.__TYPE = nil
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kulala.nvim",
"version": "1.6.0",
"version": "1.6.1",
"scripts": {
"docs": "docsify serve docs"
},
Expand Down

0 comments on commit 9d59626

Please sign in to comment.