mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
Enhance post-update hook output
This commit is contained in:
parent
38e1e6335c
commit
e00be1b493
13
plug.vim
13
plug.vim
@ -656,6 +656,7 @@ function! s:do(pull, force, todo)
|
||||
if a:force || installed || updated
|
||||
execute 'cd' s:esc(spec.dir)
|
||||
call append(3, '- Post-update hook for '. name .' ... ')
|
||||
let error = ''
|
||||
let type = type(spec.do)
|
||||
if type == s:TYPE.string
|
||||
try
|
||||
@ -664,21 +665,23 @@ function! s:do(pull, force, todo)
|
||||
let g:_plug_do = '!'.escape(spec.do, '#!%')
|
||||
execute "normal! :execute g:_plug_do\<cr>\<cr>"
|
||||
finally
|
||||
let result = v:shell_error ? ('Exit status: '.v:shell_error) : 'Done!'
|
||||
if v:shell_error
|
||||
let error = 'Exit status: ' . v:shell_error
|
||||
endif
|
||||
unlet g:_plug_do
|
||||
endtry
|
||||
elseif type == s:TYPE.funcref
|
||||
try
|
||||
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
|
||||
call spec.do({ 'name': name, 'status': status, 'force': a:force })
|
||||
let result = 'Done!'
|
||||
catch
|
||||
let result = 'Error: ' . v:exception
|
||||
let error = v:exception
|
||||
endtry
|
||||
else
|
||||
let result = 'Error: Invalid type!'
|
||||
let error = 'Invalid hook type'
|
||||
endif
|
||||
call setline(4, getline(4) . result)
|
||||
call setline(4, empty(error) ? (getline(4) . 'OK')
|
||||
\ : ('x' . getline(4)[1:] . error))
|
||||
cd -
|
||||
endif
|
||||
endfor
|
||||
|
@ -756,6 +756,28 @@ Execute (Using Funcref):
|
||||
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
|
||||
\ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
|
||||
|
||||
Execute (Post-update hook output; success and failure):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-easy-align', { 'do': 'xxx-non-existent-command-xxx' }
|
||||
Plug 'junegunn/vim-pseudocl', { 'do': 'true' }
|
||||
call plug#end()
|
||||
|
||||
silent PlugInstall! 1
|
||||
AssertEqual '- Post-update hook for vim-pseudocl ... OK', getline(5)
|
||||
AssertEqual 'x Post-update hook for vim-easy-align ... Exit status: 127', getline(6)
|
||||
q
|
||||
|
||||
Execute (Post-update hook output; invalid type or funcref):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-easy-align', { 'do': 1 }
|
||||
Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
|
||||
call plug#end()
|
||||
|
||||
silent PlugInstall! 1
|
||||
AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
|
||||
AssertEqual 'x Post-update hook for vim-easy-align ... Invalid hook type', getline(6)
|
||||
q
|
||||
|
||||
Execute (Should not run when failed to update):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-easy-align', { 'do': 'touch failed' }
|
||||
|
Loading…
Reference in New Issue
Block a user