diff --git a/lua/dep.lua b/lua/dep.lua index ca179c5..2ae3105 100755 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -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(