Skip to content

Commit 5bcb9b8

Browse files
authored
feat: add Path:find_upwards (#466)
1 parent f7db41f commit 5bcb9b8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lua/plenary/path.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,4 +918,16 @@ function Path:readbyterange(offset, length)
918918
return data
919919
end
920920

921+
function Path:find_upwards(filename)
922+
local folder = Path:new(self)
923+
while self:absolute() ~= path.root do
924+
local p = folder:joinpath(filename)
925+
if p:exists() then
926+
return p
927+
end
928+
folder = folder:parent()
929+
end
930+
return ""
931+
end
932+
921933
return Path

0 commit comments

Comments
 (0)