From bd7aa5db149012c54aea228839e44aa8d1b53a15 Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Wed, 8 Jan 2020 17:21:18 +0100
Subject: Rename VS Code extension to rust-analyzer

---
 xtask/src/install.rs | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

(limited to 'xtask/src')

diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index fa82633de..bffd91af1 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -107,29 +107,44 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
     };
 
     Cmd {
-        unix: &format!(r"{} --install-extension ./ra-lsp-0.0.1.vsix --force", code_binary),
+        unix: &format!(r"{} --install-extension ./rust-analyzer-0.1.0.vsix --force", code_binary),
         windows: &format!(
-            r"cmd.exe /c {}.cmd --install-extension ./ra-lsp-0.0.1.vsix --force",
+            r"cmd.exe /c {}.cmd --install-extension ./rust-analyzer-0.1.0.vsix --force",
             code_binary
         ),
         work_dir: "./editors/code",
     }
     .run()?;
 
-    let output = Cmd {
-        unix: &format!(r"{} --list-extensions", code_binary),
-        windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary),
-        work_dir: ".",
-    }
-    .run_with_output()?;
+    let installed_extensions = {
+        let output = Cmd {
+            unix: &format!(r"{} --list-extensions", code_binary),
+            windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary),
+            work_dir: ".",
+        }
+        .run_with_output()?;
+        String::from_utf8(output.stdout)?
+    };
 
-    if !str::from_utf8(&output.stdout)?.contains("ra-lsp") {
+    if !installed_extensions.contains("rust-analyzer") {
         anyhow::bail!(
             "Could not install the Visual Studio Code extension. \
              Please make sure you have at least NodeJS 10.x together with the latest version of VS Code installed and try again."
         );
     }
 
+    if installed_extensions.contains("ra-lsp") {
+        Cmd {
+            unix: &format!(r"{} --uninstall-extension matklad.ra-lsp", code_binary),
+            windows: &format!(
+                r"cmd.exe /c {}.cmd --uninstall-extension matklad.ra-lsp",
+                code_binary
+            ),
+            work_dir: "./editors/code",
+        }
+        .run()?;
+    }
+
     Ok(())
 }
 
-- 
cgit v1.2.3