Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Change directory into the package dir when running hooks #2

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/dep.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,22 @@ local function run_hooks(package, type)

local start = os.clock()

-- chdir into the package directory to make running external commands
-- from hooks easier.
local last_cwd = vim.fn.getcwd()
vim.fn.chdir(package.dir)

for i = 1, #hooks do
local ok, err = pcall(hooks[i])
if not ok then
vim.fn.chdir(last_cwd)

package.error = true
return false, err
end
end

vim.fn.chdir(last_cwd)
package.perf[type] = os.clock() - start

logger:log(
Expand Down