Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronous external command execution independent of shell #131

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ jobs:
- name: Clone vim-jetpack
uses: actions/checkout@v3

- uses: ilammy/msvc-dev-cmd@v1
- name: Install Lua
uses: leafo/gh-actions-lua@v10
if: ${{ contains(matrix.os, 'windows') }}
run: |
Invoke-WebRequest -Uri https://joedf.ahkscript.org/LuaBuilds/hdata/lua-5.4.4_Win64_bin.zip -OutFile .\Lua.zip
Expand-Archive .\Lua.zip C:\Lua
Add-Content $env:GITHUB_PATH C:\Lua

- name: Install vim-themis
uses: actions/checkout@v3
Expand Down
23 changes: 18 additions & 5 deletions plugin/jetpack.vim
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
\ 'on_exit': { _, st -> st != 0 ? execute("echoerr '`'.join(a:cmd, ' ').'`:'.join(buf, '')") : a:cb(join(buf, '')) }
\ })
endfunction

function! jetpack#system(cmd) abort
return a:cmd->split(" ")->system()

Check failure on line 165 in plugin/jetpack.vim

View workflow job for this annotation

GitHub Actions / Lint

[vint] reported by reviewdog 🐶 E488: Trailing characters: - (see vim-jp/vim-vimlparser) Raw Output: plugin/jetpack.vim:165:17: E488: Trailing characters: - (see vim-jp/vim-vimlparser)
endfunction
else
function! jetpack#jobstart(cmd, cb) abort
let buf = []
Expand All @@ -171,6 +175,15 @@
\ 'exit_cb': function('jetpack#nvim_exit_cb', [a:cmd, buf, a:cb])
\ })
endfunction

function! jetpack#system(cmd) abort
let buf = []
let job = job_start(a:cmd, {
\ 'out_cb': { _, data -> extend(buf, split(data, "\n")) }
\})
call jetpack#jobwait([job], 0)
return buf->join("\n")
endfunction
endif

function! jetpack#initialize_buffer() abort
Expand Down Expand Up @@ -235,8 +248,8 @@
continue
endif
if isdirectory(pkg.path)
call system(printf('git -C %s reset --hard', pkg.path))
let branch = trim(system(printf('git -C %s rev-parse --abbrev-ref %s', pkg.path, pkg.commit)))
call jetpack#system(printf('git -C %s reset --hard', pkg.path))
let branch = trim(jetpack#system(printf('git -C %s rev-parse --abbrev-ref %s', pkg.path, pkg.commit)))
if v:shell_error && !empty(pkg.commit)
call delete(pkg.path, 'rf')
continue
Expand Down Expand Up @@ -356,7 +369,7 @@
call add(jobs, job)
call jetpack#jobwait(jobs, g:jetpack_njobs)
else
let pkg.output = join(map(cmds, { _, cmd -> system(cmd) }), "\n")
let pkg.output = join(map(cmds, { _, cmd -> jetpack#system(cmd) }), "\n")
call add(pkg.status, status)
endif
endfor
Expand All @@ -378,7 +391,7 @@
else
call add(pkg.status, s:status.switched)
endif
call system(printf('git -C %s checkout %s', pkg.path, pkg.commit))
call jetpack#system(printf('git -C %s checkout %s', pkg.path, pkg.commit))
endfor
endfunction

Expand All @@ -395,7 +408,7 @@
if pkg.do =~# '^:'
execute pkg.do
else
call system(pkg.do)
call jetpack#system(pkg.do)
endif
endif
call chdir(pwd)
Expand Down
Loading