Skip to content
Open
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
55 changes: 34 additions & 21 deletions autoload/denops/cache.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,42 @@ let s:job = v:null
function! denops#cache#update(...) abort
const l:options = extend(#{ reload: v:false }, a:0 ? a:1 : {})
const l:plugins = denops#_internal#plugin#list()
const l:entryfiles = extend([s:mod], mapnew(l:plugins, { _, v -> v.script }))
let l:failures = []

let l:args = [g:denops#deno, 'cache']

if l:options.reload
let l:args = add(l:args, '--reload')
echomsg '[denops] Forcibly update cache of the following files.'
else
if !l:options.reload
echomsg '[denops] Update cache of the following files. Call `denops#cache#update(#{reload: v:true})` to forcibly update.'
endif

for l:entryfile in l:entryfiles
for l:entryfile in [s:mod] + mapnew(l:plugins, { _, v -> v.script })
echomsg printf('[denops] %s', l:entryfile)

let l:args = [g:denops#deno, 'cache']
if l:options.reload
let l:args = add(l:args, '--reload')
endif
let l:args = add(l:args, l:entryfile)

let s:job = denops#_internal#job#start(l:args, #{
\ on_stderr: funcref('s:on_stderr'),
\ on_exit: funcref('s:on_exit', [l:failures, l:entryfile]),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
endfor
let l:args = extend(l:args, l:entryfiles)

let s:job = denops#_internal#job#start(l:args, #{
\ on_stderr: funcref('s:on_stderr'),
\ on_exit: funcref('s:on_exit'),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
echomsg '[denops] Deno cache is updated.'

if empty(l:failures)
echomsg '[denops] Deno cache is updated.'
else
echohl WarningMsg
echomsg printf('[denops] Deno cache finished with errors: %d failure(s).', len(l:failures))
for l:f in l:failures
echomsg printf('[denops] failed: %s', l:f)
endfor
echohl None
endif
endfunction

function! s:on_stderr(job, data, event) abort
Expand All @@ -41,6 +51,9 @@ function! s:on_stderr(job, data, event) abort
echohl None
endfunction

function! s:on_exit(job, status, event) abort
function! s:on_exit(failures, entryfile, job, status, event) abort
if a:status != 0
call add(a:failures, a:entryfile)
endif
let s:job = v:null
endfunction
Loading