feat(fs): add vim.fs.find()

This is a pure Lua implementation of the Vim findfile() and finddir()
functions without the special syntax.
This commit is contained in:
Gregory Anders
2022-05-15 20:37:35 -06:00
parent 2a62bec37c
commit f271d70661
3 changed files with 170 additions and 0 deletions

View File

@@ -66,4 +66,17 @@ describe('vim.fs', function()
]], nvim_dir, nvim_prog_basename))
end)
end)
describe('find()', function()
it('works', function()
eq({test_build_dir}, exec_lua([[
local dir = ...
return vim.fs.find('build', { path = dir, upward = true, type = 'directory' })
]], nvim_dir))
eq({nvim_prog}, exec_lua([[
local dir, nvim = ...
return vim.fs.find(nvim, { path = dir, type = 'file' })
]], test_build_dir, nvim_prog_basename))
end)
end)
end)