mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 11:24:14 +00:00
fix: Always run build tasks in the plugin directory
Before this, only shell commands were run in the plugin directory. This ensures a coherent behavior by always changing to the plugin directory for build tasks.
This commit is contained in:
parent
dac844ed61
commit
8c22f4d022
1 changed files with 13 additions and 2 deletions
|
@ -15,6 +15,13 @@ local function get_build_file(plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function do_in_dir(dir, fn)
|
||||||
|
local d = vim.loop.getcwd()
|
||||||
|
vim.loop.chdir(dir)
|
||||||
|
fn()
|
||||||
|
vim.loop.chdir(d)
|
||||||
|
end
|
||||||
|
|
||||||
M.build = {
|
M.build = {
|
||||||
---@param opts? {force:boolean}
|
---@param opts? {force:boolean}
|
||||||
skip = function(plugin, opts)
|
skip = function(plugin, opts)
|
||||||
|
@ -52,9 +59,13 @@ M.build = {
|
||||||
for _, build in ipairs(builders) do
|
for _, build in ipairs(builders) do
|
||||||
if type(build) == "string" and build:sub(1, 1) == ":" then
|
if type(build) == "string" and build:sub(1, 1) == ":" then
|
||||||
local cmd = vim.api.nvim_parse_cmd(build:sub(2), {})
|
local cmd = vim.api.nvim_parse_cmd(build:sub(2), {})
|
||||||
self.output = vim.api.nvim_cmd(cmd, { output = true })
|
do_in_dir(self.plugin.dir, function()
|
||||||
|
self.output = vim.api.nvim_cmd(cmd, { output = true })
|
||||||
|
end)
|
||||||
elseif type(build) == "function" then
|
elseif type(build) == "function" then
|
||||||
build(self.plugin)
|
do_in_dir(self.plugin.dir, function()
|
||||||
|
build(self.plugin)
|
||||||
|
end)
|
||||||
else
|
else
|
||||||
local shell = vim.env.SHELL or vim.o.shell
|
local shell = vim.env.SHELL or vim.o.shell
|
||||||
local shell_args = shell:find("cmd.exe", 1, true) and "/c" or "-c"
|
local shell_args = shell:find("cmd.exe", 1, true) and "/c" or "-c"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue