diff options
Diffstat (limited to 'xtask/src/install.rs')
-rw-r--r-- | xtask/src/install.rs | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index f89c939b5..540a66130 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -1,11 +1,10 @@ | |||
1 | //! Installs rust-analyzer language server and/or editor plugin. | 1 | //! Installs rust-analyzer language server and/or editor plugin. |
2 | 2 | ||
3 | use std::{env, fs, path::PathBuf, str}; | 3 | use std::{env, path::PathBuf, str}; |
4 | 4 | ||
5 | use anyhow::{bail, format_err, Context, Result}; | 5 | use anyhow::{bail, format_err, Context, Result}; |
6 | use walkdir::WalkDir; | ||
7 | 6 | ||
8 | use crate::not_bash::{pushd, run}; | 7 | use crate::not_bash::{ls, pushd, rm, run}; |
9 | 8 | ||
10 | // Latest stable, feel free to send a PR if this lags behind. | 9 | // Latest stable, feel free to send a PR if this lags behind. |
11 | const REQUIRED_RUST_VERSION: u32 = 41; | 10 | const REQUIRED_RUST_VERSION: u32 = 41; |
@@ -85,15 +84,6 @@ fn fix_path_for_mac() -> Result<()> { | |||
85 | fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | 84 | fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { |
86 | let _dir = pushd("./editors/code"); | 85 | let _dir = pushd("./editors/code"); |
87 | 86 | ||
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 | |||
97 | let find_code = |f: fn(&str) -> bool| -> Result<&'static str> { | 87 | let find_code = |f: fn(&str) -> bool| -> Result<&'static str> { |
98 | ["code", "code-insiders", "codium", "code-oss"] | 88 | ["code", "code-insiders", "codium", "code-oss"] |
99 | .iter() | 89 | .iter() |
@@ -110,13 +100,13 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
110 | run!("npm install")?; | 100 | run!("npm install")?; |
111 | 101 | ||
112 | let vsix_pkg = { | 102 | let vsix_pkg = { |
113 | list_vsixes().try_for_each(fs::remove_file)?; | 103 | rm("*.vsix")?; |
114 | run!("npm run package --scripts-prepend-node-path")?; | 104 | 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() |
116 | }; | 106 | }; |
117 | 107 | ||
118 | let code = find_code(|bin| run!("{} --version", bin).is_ok())?; | 108 | 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())?; |
120 | installed_extensions = run!("{} --list-extensions", code; echo = false)?; | 110 | installed_extensions = run!("{} --list-extensions", code; echo = false)?; |
121 | } else { | 111 | } else { |
122 | run!("cmd.exe /c npm --version") | 112 | run!("cmd.exe /c npm --version") |
@@ -124,13 +114,13 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
124 | run!("cmd.exe /c npm install")?; | 114 | run!("cmd.exe /c npm install")?; |
125 | 115 | ||
126 | let vsix_pkg = { | 116 | let vsix_pkg = { |
127 | list_vsixes().try_for_each(fs::remove_file)?; | 117 | rm("*.vsix")?; |
128 | run!("cmd.exe /c npm run package")?; | 118 | 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() |
130 | }; | 120 | }; |
131 | 121 | ||
132 | let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?; | 122 | 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())?; |
134 | installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; | 124 | installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; |
135 | } | 125 | } |
136 | 126 | ||