mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
committed by
Lewis Russell
parent
7342e6b00d
commit
ad3472e291
@ -230,6 +230,8 @@ local function default_handler(stream, text, bucket)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local is_win = vim.fn.has('win32') == 1
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
--- @param cmd string
|
--- @param cmd string
|
||||||
@ -238,6 +240,13 @@ local M = {}
|
|||||||
--- @param on_error fun()
|
--- @param on_error fun()
|
||||||
--- @return uv.uv_process_t, integer
|
--- @return uv.uv_process_t, integer
|
||||||
local function spawn(cmd, opts, on_exit, on_error)
|
local function spawn(cmd, opts, on_exit, on_error)
|
||||||
|
if is_win then
|
||||||
|
local cmd1 = vim.fn.exepath(cmd)
|
||||||
|
if cmd1 ~= '' then
|
||||||
|
cmd = cmd1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local handle, pid_or_err = uv.spawn(cmd, opts, on_exit)
|
local handle, pid_or_err = uv.spawn(cmd, opts, on_exit)
|
||||||
if not handle then
|
if not handle then
|
||||||
on_error()
|
on_error()
|
||||||
|
@ -2165,6 +2165,7 @@ M.funcs = {
|
|||||||
If {expr} starts with "./" the |current-directory| is used.
|
If {expr} starts with "./" the |current-directory| is used.
|
||||||
|
|
||||||
]=],
|
]=],
|
||||||
|
fast = true,
|
||||||
name = 'exepath',
|
name = 'exepath',
|
||||||
params = { { 'expr', 'string' } },
|
params = { { 'expr', 'string' } },
|
||||||
signature = 'exepath({expr})',
|
signature = 'exepath({expr})',
|
||||||
|
@ -9,7 +9,7 @@ local function system_sync(cmd, opts)
|
|||||||
return exec_lua(function()
|
return exec_lua(function()
|
||||||
local obj = vim.system(cmd, opts)
|
local obj = vim.system(cmd, opts)
|
||||||
|
|
||||||
if opts.timeout then
|
if opts and opts.timeout then
|
||||||
-- Minor delay before calling wait() so the timeout uv timer can have a headstart over the
|
-- Minor delay before calling wait() so the timeout uv timer can have a headstart over the
|
||||||
-- internal call to vim.wait() in wait().
|
-- internal call to vim.wait() in wait().
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
@ -75,7 +75,7 @@ describe('vim.system', function()
|
|||||||
|
|
||||||
it('kill processes', function()
|
it('kill processes', function()
|
||||||
exec_lua(function()
|
exec_lua(function()
|
||||||
local signal
|
local signal --- @type integer?
|
||||||
local cmd = vim.system({ 'cat', '-' }, { stdin = true }, function(r)
|
local cmd = vim.system({ 'cat', '-' }, { stdin = true }, function(r)
|
||||||
signal = r.signal
|
signal = r.signal
|
||||||
end) -- run forever
|
end) -- run forever
|
||||||
@ -112,4 +112,12 @@ describe('vim.system', function()
|
|||||||
)
|
)
|
||||||
eq(true, exec_lua([[return _G.processed]]))
|
eq(true, exec_lua([[return _G.processed]]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if t.is_os('win') then
|
||||||
|
it('can resolve windows command extentions.', function()
|
||||||
|
t.write_file('test.bat', 'echo hello world')
|
||||||
|
system_sync({ 'chmod', '+x', 'test.bat' })
|
||||||
|
system_sync({ './test' })
|
||||||
|
end)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user