fix refactor pt 6
This commit is contained in:
parent
a030434bf0
commit
f19561b13f
|
@ -1,20 +1,21 @@
|
||||||
return {
|
|
||||||
pick_executable = function(start_dir)
|
|
||||||
local function is_executable(path)
|
local function is_executable(path)
|
||||||
return vim.fn.filereadable(path) == 1 and vim.fn.executable(path) == 1
|
-- Use `file` command to identify Mach-O or ELF binaries
|
||||||
|
local output = vim.fn.system { 'file', '-b', path }
|
||||||
|
return output:match 'Mach%-O' or output:match 'ELF'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function collect_executables(dir)
|
local function collect_executables(dir)
|
||||||
local files = vim.fn.globpath(dir, '**', true, true)
|
local files = vim.fn.globpath(dir, '**', true, true)
|
||||||
local binaries = {}
|
local binaries = {}
|
||||||
for _, path in ipairs(files) do
|
for _, path in ipairs(files) do
|
||||||
if is_executable(path) then
|
if vim.fn.filereadable(path) == 1 and is_executable(path) then
|
||||||
table.insert(binaries, path)
|
table.insert(binaries, path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return binaries
|
return binaries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pick_executable(start_dir)
|
||||||
local co = coroutine.running()
|
local co = coroutine.running()
|
||||||
if not co then
|
if not co then
|
||||||
error 'pick_executable must be called from a coroutine'
|
error 'pick_executable must be called from a coroutine'
|
||||||
|
@ -45,5 +46,8 @@ return {
|
||||||
:find()
|
:find()
|
||||||
|
|
||||||
return coroutine.yield()
|
return coroutine.yield()
|
||||||
end,
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
pick_executable = pick_executable,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue