diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/install.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index a279598b9..9bddc8d7f 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -1,8 +1,9 @@ | |||
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, path::PathBuf, str}; | 3 | use std::{env, fs, 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; | ||
6 | 7 | ||
7 | use crate::cmd::{run, run_with_output, Cmd}; | 8 | use crate::cmd::{run, run_with_output, Cmd}; |
8 | 9 | ||
@@ -95,6 +96,20 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
95 | 96 | ||
96 | Cmd { unix: r"npm install", windows: r"cmd.exe /c npm install", work_dir: "./editors/code" } | 97 | Cmd { unix: r"npm install", windows: r"cmd.exe /c npm install", work_dir: "./editors/code" } |
97 | .run()?; | 98 | .run()?; |
99 | |||
100 | let vsixes = || { | ||
101 | WalkDir::new("./editors/code") | ||
102 | .max_depth(1) | ||
103 | .into_iter() | ||
104 | .map(|it| it.unwrap()) | ||
105 | .map(|it| it.path().to_owned()) | ||
106 | .filter(|it| it.file_name().unwrap_or_default().to_string_lossy().ends_with(".vsix")) | ||
107 | }; | ||
108 | |||
109 | for path in vsixes() { | ||
110 | fs::remove_file(path)? | ||
111 | } | ||
112 | |||
98 | Cmd { | 113 | Cmd { |
99 | unix: r"npm run package --scripts-prepend-node-path", | 114 | unix: r"npm run package --scripts-prepend-node-path", |
100 | windows: r"cmd.exe /c npm run package", | 115 | windows: r"cmd.exe /c npm run package", |
@@ -102,6 +117,8 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
102 | } | 117 | } |
103 | .run()?; | 118 | .run()?; |
104 | 119 | ||
120 | let extension = vsixes().next().unwrap().file_name().unwrap().to_string_lossy().to_string(); | ||
121 | |||
105 | let code_binary = ["code", "code-insiders", "codium", "code-oss"] | 122 | let code_binary = ["code", "code-insiders", "codium", "code-oss"] |
106 | .iter() | 123 | .iter() |
107 | .find(|bin| { | 124 | .find(|bin| { |
@@ -118,10 +135,10 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
118 | })?; | 135 | })?; |
119 | 136 | ||
120 | Cmd { | 137 | Cmd { |
121 | unix: &format!(r"{} --install-extension ./rust-analyzer-0.1.0.vsix --force", code_binary), | 138 | unix: &format!(r"{} --install-extension ./{} --force", code_binary, extension), |
122 | windows: &format!( | 139 | windows: &format!( |
123 | r"cmd.exe /c {}.cmd --install-extension ./rust-analyzer-0.1.0.vsix --force", | 140 | r"cmd.exe /c {}.cmd --install-extension ./{} --force", |
124 | code_binary | 141 | code_binary, extension |
125 | ), | 142 | ), |
126 | work_dir: "./editors/code", | 143 | work_dir: "./editors/code", |
127 | } | 144 | } |