11//! Installs rust-analyzer language server and/or editor plugin.
22
3- use std:: { env, fs , path:: PathBuf , str} ;
3+ use std:: { env, path:: PathBuf , str} ;
44
55use anyhow:: { bail, format_err, Context , Result } ;
6- use walkdir:: WalkDir ;
76
8- use crate :: not_bash:: { pushd, run} ;
7+ use crate :: not_bash:: { ls , pushd, rm , run} ;
98
109// Latest stable, feel free to send a PR if this lags behind.
1110const REQUIRED_RUST_VERSION : u32 = 41 ;
@@ -85,15 +84,6 @@ fn fix_path_for_mac() -> Result<()> {
8584fn install_client ( ClientOpt :: VsCode : ClientOpt ) -> Result < ( ) > {
8685 let _dir = pushd ( "./editors/code" ) ;
8786
88- let list_vsixes = || {
89- WalkDir :: new ( "./editors/code" )
90- . max_depth ( 1 )
91- . into_iter ( )
92- . map ( |it| it. unwrap ( ) )
93- . map ( |it| it. path ( ) . to_owned ( ) )
94- . filter ( |it| it. file_name ( ) . unwrap_or_default ( ) . to_string_lossy ( ) . ends_with ( ".vsix" ) )
95- } ;
96-
9787 let find_code = |f : fn ( & str ) -> bool | -> Result < & ' static str > {
9888 [ "code" , "code-insiders" , "codium" , "code-oss" ]
9989 . iter ( )
@@ -110,27 +100,27 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
110100 run ! ( "npm install" ) ?;
111101
112102 let vsix_pkg = {
113- list_vsixes ( ) . try_for_each ( fs :: remove_file ) ?;
103+ rm ( "*.vsix" ) ?;
114104 run ! ( "npm run package --scripts-prepend-node-path" ) ?;
115- list_vsixes ( ) . next ( ) . unwrap ( ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( )
105+ ls ( "*.vsix" ) ? . pop ( ) . unwrap ( )
116106 } ;
117107
118108 let code = find_code ( |bin| run ! ( "{} --version" , bin) . is_ok ( ) ) ?;
119- run ! ( "{} --install-extension ./ {} --force" , code, vsix_pkg) ?;
109+ run ! ( "{} --install-extension {} --force" , code, vsix_pkg. display ( ) ) ?;
120110 installed_extensions = run ! ( "{} --list-extensions" , code; echo = false ) ?;
121111 } else {
122112 run ! ( "cmd.exe /c npm --version" )
123113 . context ( "`npm` is required to build the VS Code plugin" ) ?;
124114 run ! ( "cmd.exe /c npm install" ) ?;
125115
126116 let vsix_pkg = {
127- list_vsixes ( ) . try_for_each ( fs :: remove_file ) ?;
117+ rm ( "*.vsix" ) ?;
128118 run ! ( "cmd.exe /c npm run package" ) ?;
129- list_vsixes ( ) . next ( ) . unwrap ( ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( )
119+ ls ( "*.vsix" ) ? . pop ( ) . unwrap ( )
130120 } ;
131121
132122 let code = find_code ( |bin| run ! ( "cmd.exe /c {}.cmd --version" , bin) . is_ok ( ) ) ?;
133- run ! ( r"cmd.exe /c {}.cmd --install-extension ./ {} --force" , code, vsix_pkg) ?;
123+ run ! ( r"cmd.exe /c {}.cmd --install-extension {} --force" , code, vsix_pkg. display ( ) ) ?;
134124 installed_extensions = run ! ( "cmd.exe /c {}.cmd --list-extensions" , code; echo = false ) ?;
135125 }
136126
0 commit comments