|
| 1 | +let s:root = expand('<sfile>:p:h:h:h') |
| 2 | +let s:job = v:null |
| 3 | + |
| 4 | +function! denops#cache#update(...) abort |
| 5 | + let l:options = extend(#{ reload: v:false }, a:0 ? a:1 : {}) |
| 6 | + let l:entryfiles = extend([ |
| 7 | + \ denops#_internal#path#join([s:root, 'denops', '@denops-private', 'mod.ts']), |
| 8 | + \], map(denops#_internal#plugin#collect(), { _, v -> v.script })) |
| 9 | + |
| 10 | + let l:args = [g:denops#deno, 'cache'] |
| 11 | + |
| 12 | + if l:options.reload |
| 13 | + let l:args = add(l:args, '--reload') |
| 14 | + echomsg '[denops] Forcibly update cache of the following files.' |
| 15 | + else |
| 16 | + echomsg '[denops] Update cache of the following files. Call `denops#cache#update(#{reload: v:true})` to forcibly update.' |
| 17 | + endif |
| 18 | + |
| 19 | + for l:entryfile in l:entryfiles |
| 20 | + echomsg printf('[denops] %s', l:entryfile) |
| 21 | + endfor |
| 22 | + let l:args = extend(l:args, l:entryfiles) |
| 23 | + |
| 24 | + let s:job = denops#_internal#job#start(l:args, #{ |
| 25 | + \ on_stderr: funcref('s:on_stderr'), |
| 26 | + \ on_exit: funcref('s:on_exit'), |
| 27 | + \ env: #{ |
| 28 | + \ NO_COLOR: 1, |
| 29 | + \ DENO_NO_PROMPT: 1, |
| 30 | + \ }, |
| 31 | + \}) |
| 32 | + call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100) |
| 33 | + echomsg '[denops] Deno cache is updated.' |
| 34 | +endfunction |
| 35 | + |
| 36 | +function! s:on_stderr(job, data, event) abort |
| 37 | + echohl Comment |
| 38 | + for l:line in split(a:data, '\n') |
| 39 | + echomsg printf('[denops] %s', substitute(l:line, '\t', ' ', 'g')) |
| 40 | + endfor |
| 41 | + echohl None |
| 42 | +endfunction |
| 43 | + |
| 44 | +function! s:on_exit(job, status, event) abort |
| 45 | + let s:job = v:null |
| 46 | +endfunction |
0 commit comments