Skip to content

Commit

Permalink
feat: ignore_missing delete_task_bundle option
Browse files Browse the repository at this point in the history
  • Loading branch information
derethil committed Oct 25, 2024
1 parent 7f7195c commit 16c9f29
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/overseer/task_bundle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ M.save_task_bundle = function(name, tasks, opts)
end
if vim.tbl_isempty(serialized) then
if opts.on_conflict == "overwrite" then
M.delete_task_bundle(name)
M.delete_task_bundle(name, { ignore_missing = true })
end
return
end
Expand Down Expand Up @@ -208,11 +208,19 @@ M.save_task_bundle = function(name, tasks, opts)
end

---@param name? string
M.delete_task_bundle = function(name)
---@param opts? {ignore_missing?: boolean}
M.delete_task_bundle = function(name, opts)
vim.validate({
name = { name, "s", true },
opts = { opts, "t", true },
})
opts = opts or {}
if name then
local filename = string.format("%s.bundle.json", name)
if not files.delete_file(files.join(get_bundle_dir(), filename)) then
vim.notify(string.format("No task bundle at %s", filename))
if not opts.ignore_missing then
vim.notify(string.format("No task bundle at %s", filename))
end
end
else
local tasks = M.list_task_bundles()
Expand Down

0 comments on commit 16c9f29

Please sign in to comment.