Skip to content

Commit

Permalink
feat: add Path:find_upwards (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
obreitwi committed May 24, 2023
1 parent f7db41f commit 5bcb9b8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/plenary/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,16 @@ function Path:readbyterange(offset, length)
return data
end

function Path:find_upwards(filename)
local folder = Path:new(self)
while self:absolute() ~= path.root do
local p = folder:joinpath(filename)
if p:exists() then
return p
end
folder = folder:parent()
end
return ""
end

return Path

0 comments on commit 5bcb9b8

Please sign in to comment.