Skip to content

Commit

Permalink
fix(functions): proper env variables file loading order, fixes #308
Browse files Browse the repository at this point in the history
  • Loading branch information
NTBBloodbath committed Mar 19, 2024
1 parent 2387bc5 commit 2030bf6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lua/rest-nvim/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function functions.exec(scope)
local req_results = {}

if scope == "cursor" then
-- Load environment variables from the env file before parsing the request
env_vars.read_file(true)

local req = parser.parse(
---@diagnostic disable-next-line param-type-mismatch
parser.look_behind_until(parser.get_node_at_cursor(), "request")
Expand All @@ -65,8 +68,6 @@ function functions.exec(scope)
-- Set up a _rest_nvim_req_data Lua global table that holds the parsed request
-- so the values can be modified from the pre-request hooks
_G._rest_nvim_req_data = req
-- Load environment variables from the env file
env_vars.read_file(true)
-- Run pre-request hooks
api.exec_pre_request_hooks()
-- Clean the _rest_nvim_req_data global after running the pre-request hooks
Expand Down Expand Up @@ -98,8 +99,6 @@ function functions.exec(scope)
-- Set up a _rest_nvim_req_data Lua global table that holds the parsed request
-- so the values can be modified from the pre-request hooks
_G._rest_nvim_req_data = req
-- Load environment variables from the env file
env_vars.read_file(true)
-- Run pre-request hooks
api.exec_pre_request_hooks()
-- Clean the _rest_nvim_req_data global after running the pre-request hooks
Expand Down

0 comments on commit 2030bf6

Please sign in to comment.