refactor(unit): add type annotations

This commit is contained in:
Lewis Russell
2023-04-03 12:01:23 +01:00
parent 5465adcbab
commit 3d29424fb9
5 changed files with 313 additions and 248 deletions

View File

@@ -20,12 +20,16 @@ local module = {
REMOVE_THIS = {},
}
--- @param p string
--- @return string
local function relpath(p)
p = vim.fs.normalize(p)
local cwd = luv.cwd()
return p:gsub("^" .. cwd)
end
--- @param path string
--- @return boolean
function module.isdir(path)
if not path then
return false
@@ -37,6 +41,8 @@ function module.isdir(path)
return stat.type == 'directory'
end
--- @param path string
--- @return boolean
function module.isfile(path)
if not path then
return false
@@ -48,6 +54,7 @@ function module.isfile(path)
return stat.type == 'file'
end
--- @return string
function module.argss_to_cmd(...)
local cmd = ''
for i = 1, select('#', ...) do
@@ -462,6 +469,7 @@ function module.check_cores(app, force) -- luacheck: ignore
end
end
--- @return string?
function module.repeated_read_cmd(...)
for _ = 1, 10 do
local stream = module.popen_r(...)
@@ -561,6 +569,9 @@ function module.concat_tables(...)
return ret
end
--- @param str string
--- @param leave_indent? boolean
--- @return string
function module.dedent(str, leave_indent)
-- find minimum common indent across lines
local indent = nil