Skip to content

Commit

Permalink
feat: finds root (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasia authored Nov 12, 2023
1 parent 455dc99 commit 0aa39c4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/neotest-bash/core/root_finder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ SpecBuilder = {}
---@param dir string @Directory to treat as cwd
---@return string | nil @Absolute root dir of test suite
function SpecBuilder.findRoot(dir)
return lib.files.match_root_pattern("????")(dir)
-- TODO: check what happens when it's a single file
local matchers = {
".git",
"lib",
}
for _, matcher in ipairs(matchers) do
local root = lib.files.match_root_pattern(matcher)(dir)
if root then
return root
end
end

return nil
end

return SpecBuilder

0 comments on commit 0aa39c4

Please sign in to comment.