aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_tools/src/lib.rs10
-rw-r--r--crates/ra_tools/src/main.rs35
2 files changed, 26 insertions, 19 deletions
diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs
index d47660369..9ba23caaa 100644
--- a/crates/ra_tools/src/lib.rs
+++ b/crates/ra_tools/src/lib.rs
@@ -79,13 +79,13 @@ pub fn project_root() -> PathBuf {
79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf() 79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf()
80} 80}
81 81
82pub struct Cmd { 82pub struct Cmd<'a> {
83 pub unix: &'static str, 83 pub unix: &'a str,
84 pub windows: &'static str, 84 pub windows: &'a str,
85 pub work_dir: &'static str, 85 pub work_dir: &'a str,
86} 86}
87 87
88impl Cmd { 88impl Cmd<'_> {
89 pub fn run(self) -> Result<()> { 89 pub fn run(self) -> Result<()> {
90 if cfg!(windows) { 90 if cfg!(windows) {
91 run(self.windows, self.work_dir) 91 run(self.windows, self.work_dir)
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()?;