Skip to content

Commit f23ddb6

Browse files
committed
fix: separate powershell commands to function
1 parent 12a321e commit f23ddb6

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

autoload/denops_shared_server/runtray.vim

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,35 @@ function! denops_shared_server#runtray#install(options) abort
1919
call writefile(content, s:config_file, 'b')
2020

2121
call denops#util#info(printf('download the script `%s`', s:script_file))
22-
echo system(printf(
23-
\ '%s Invoke-WebRequest -URI "%s" -OutFile "%s";Unblock-File "%s"',
24-
\ s:ps_cmd,
25-
\ s:script_download_url,
26-
\ s:script_file,
27-
\ s:script_file,
28-
\))
22+
call s:download_file(s:script_download_url, s:script_file)
23+
call s:remove_zone_identifier(s:script_file)
2924

3025
call denops#util#info('install to the startup')
31-
echo system(printf('%s "%s" install', s:ps_cmd, s:script_file))
26+
call s:execute_runtray_command('install')
3227

3328
call denops#util#info('start the service')
34-
echo system(printf('%s "%s" start', s:ps_cmd, s:script_file))
29+
call s:execute_runtray_command('start')
3530
endfunction
3631

3732
function! denops_shared_server#runtray#uninstall() abort
3833
call denops#util#info('uninstall from the startup')
39-
call system(printf('%s "%s" uninstall', s:ps_cmd, s:script_file))
34+
call s:execute_runtray_command('uninstall')
4035

4136
call denops#util#info(printf('delete the configuration file `%s`', s:config_file))
4237
call delete(s:config_file)
4338

4439
call denops#util#info(printf('delete the script `%s`', s:script_file))
4540
call delete(s:script_file)
4641
endfunction
42+
43+
function s:download_file(url, outfile) abort
44+
echo system(printf('%s Invoke-WebRequest -URI "%s" -OutFile "%s"', s:ps_cmd, a:url, a:outfile))
45+
endfunction
46+
47+
function s:remove_zone_identifier(file) abort
48+
echo system(printf('%s Unblock-File "%s"', s:ps_cmd, a:file))
49+
endfunction
50+
51+
function s:execute_runtray_command(command) abort
52+
echo system(printf('%s "%s" %s', s:ps_cmd, s:script_file, a:command))
53+
endfunction

0 commit comments

Comments
 (0)