refactor(utils): flatten the dir of files
This commit is contained in:
parent
3b574efbf6
commit
c0b47fd7a3
3 changed files with 1 additions and 1 deletions
39
lua/gopher/_utils/runner.lua
Normal file
39
lua/gopher/_utils/runner.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
local c = require "gopher.config"
|
||||
local runner = {}
|
||||
|
||||
---@class gopher.RunnerOpts
|
||||
---@field cwd? string
|
||||
---@field timeout? number
|
||||
---@field stdin? boolean|string|string[]
|
||||
---@field text? boolean
|
||||
|
||||
---@param cmd (string|number)[]
|
||||
---@param on_exit fun(out:vim.SystemCompleted)
|
||||
---@param opts? gopher.RunnerOpts
|
||||
---@return vim.SystemObj
|
||||
function runner.async(cmd, on_exit, opts)
|
||||
opts = opts or {}
|
||||
return vim.system(cmd, {
|
||||
cwd = opts.cwd or nil,
|
||||
timeout = opts.timeout or c.timeout,
|
||||
stdin = opts.stdin or nil,
|
||||
text = opts.text or true,
|
||||
}, on_exit)
|
||||
end
|
||||
|
||||
---@param cmd (string|number)[]
|
||||
---@param opts? gopher.RunnerOpts
|
||||
---@return vim.SystemCompleted
|
||||
function runner.sync(cmd, opts)
|
||||
opts = opts or {}
|
||||
return vim
|
||||
.system(cmd, {
|
||||
cwd = opts.cwd or nil,
|
||||
timeout = opts.timeout or c.timeout,
|
||||
stdin = opts.stdin or nil,
|
||||
text = opts.text or true,
|
||||
})
|
||||
:wait()
|
||||
end
|
||||
|
||||
return runner
|
||||
Loading…
Add table
Add a link
Reference in a new issue