Merge pull request #2 from phosphene47/hook-chdir

This commit is contained in:
phos
2021-12-14 14:21:45 +11:00
committed by GitHub

View File

@ -240,14 +240,22 @@ 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
vim.fn.chdir(last_cwd)
package.error = true package.error = true
return false, err return false, err
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(