diff options
Diffstat (limited to 'crates/ra_tools/src/main.rs')
-rw-r--r-- | crates/ra_tools/src/main.rs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/crates/ra_tools/src/main.rs b/crates/ra_tools/src/main.rs index f96f1875f..65d211b44 100644 --- a/crates/ra_tools/src/main.rs +++ b/crates/ra_tools/src/main.rs | |||
@@ -167,27 +167,34 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
167 | } | 167 | } |
168 | .run()?; | 168 | .run()?; |
169 | 169 | ||
170 | let code_in_path = Cmd { | 170 | let code_binary = ["code", "code-insiders"].iter().find(|bin| { |
171 | unix: r"code --version", | 171 | Cmd { |
172 | windows: r"cmd.exe /c code.cmd --version", | 172 | unix: &format!("{} --version", bin), |
173 | work_dir: "./editors/code", | 173 | windows: &format!("cmd.exe /c {}.cmd --version", bin), |
174 | } | 174 | work_dir: "./editors/code", |
175 | .run() | 175 | } |
176 | .is_ok(); | 176 | .run() |
177 | if !code_in_path { | 177 | .is_ok() |
178 | Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?; | 178 | }); |
179 | } | 179 | |
180 | let code_binary = match code_binary { | ||
181 | Some(it) => it, | ||
182 | None => Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?, | ||
183 | }; | ||
180 | 184 | ||
181 | Cmd { | 185 | Cmd { |
182 | unix: r"code --install-extension ./ra-lsp-0.0.1.vsix --force", | 186 | unix: &format!(r"{} --install-extension ./ra-lsp-0.0.1.vsix --force", code_binary), |
183 | windows: r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix --force", | 187 | windows: &format!( |
188 | r"cmd.exe /c {}.cmd --install-extension ./ra-lsp-0.0.1.vsix --force", | ||
189 | code_binary | ||
190 | ), | ||
184 | work_dir: "./editors/code", | 191 | work_dir: "./editors/code", |
185 | } | 192 | } |
186 | .run()?; | 193 | .run()?; |
187 | 194 | ||
188 | let output = Cmd { | 195 | let output = Cmd { |
189 | unix: r"code --list-extensions", | 196 | unix: &format!(r"{} --list-extensions", code_binary), |
190 | windows: r"cmd.exe /c code.cmd --list-extensions", | 197 | windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary), |
191 | work_dir: ".", | 198 | work_dir: ".", |
192 | } | 199 | } |
193 | .run_with_output()?; | 200 | .run_with_output()?; |