This commit is contained in:
2026-06-19 17:07:43 +03:00
parent 5b814774cd
commit c17ed13e2a
6 changed files with 37 additions and 79 deletions

View File

@@ -21,4 +21,24 @@ function M.await(fn, timeout, interval)
return { ok = ok or false, data = data }
end
function M.root_markers_with_field(root_files, new_names, field, fname)
local path = vim.fn.fnamemodify(fname, ':h')
local found = vim.fs.find(new_names, { path = path, upward = true })
for _, file in ipairs(found or {}) do
for line in io.lines(file) do
if line:find(field) then
root_files[#root_files + 1] = vim.fs.basename(file)
break
end
end
end
return root_files
end
function M.insert_package_json(root_files, field, fname)
return M.root_markers_with_field(root_files, { 'package.json', 'package.json5' }, field, fname)
end
return M