Change directory into the package dir when running hooks

This makes running external commands like `make` from hooks easier to do.
This commit is contained in:
phosphene47
2021-12-14 14:11:41 +11:00
parent d67042b868
commit 0cd9fa1476

View File

@ -240,6 +240,11 @@ local function run_hooks(package, type)
local start = os.clock() 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 for i = 1, #hooks do
local ok, err = pcall(hooks[i]) local ok, err = pcall(hooks[i])
if not ok then if not ok then
@ -248,6 +253,7 @@ local function run_hooks(package, type)
end end
end end
vim.fn.chdir(last_cwd)
package.perf[type] = os.clock() - start package.perf[type] = os.clock() - start
logger:log( logger:log(