diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-06 12:21:55 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-06 12:21:55 +0000 |
commit | b1a1d20e067c25fb80fbab43b2956b6747a8dd3c (patch) | |
tree | 454764452ef6b6018fbb388acdf0610d51b61048 /crates/tools/src/main.rs | |
parent | bab97f1602a6cc2cc7921bf1c17ebeb3f8ae9235 (diff) | |
parent | cb60416cb59c87244a523bab464a265db7e58f04 (diff) |
Merge #933
933: Check installed extension r=matklad a=c410-f3r
Fixes #918.
Edit: Windows encoding for Unicode is UTF-16 so String::from_utf8 will probably fail unless `Vec<u8>` is already UTF-8 somehow, which I don't know for sure.
Co-authored-by: Caio <[email protected]>
Diffstat (limited to 'crates/tools/src/main.rs')
-rw-r--r-- | crates/tools/src/main.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 963ffbe98..4a1b2ff9a 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -1,7 +1,8 @@ | |||
1 | use clap::{App, SubCommand}; | 1 | use clap::{App, SubCommand}; |
2 | 2 | use core::str; | |
3 | use failure::bail; | ||
3 | use tools::{ | 4 | use tools::{ |
4 | generate, gen_tests, install_format_hook, run, run_rustfmt, | 5 | generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt, |
5 | Overwrite, Result, run_fuzzer, | 6 | Overwrite, Result, run_fuzzer, |
6 | }; | 7 | }; |
7 | 8 | ||
@@ -44,5 +45,21 @@ fn install_code_extension() -> Result<()> { | |||
44 | } else { | 45 | } else { |
45 | run(r"code --install-extension ./ra-lsp-0.0.1.vsix --force", "./editors/code")?; | 46 | run(r"code --install-extension ./ra-lsp-0.0.1.vsix --force", "./editors/code")?; |
46 | } | 47 | } |
48 | verify_installed_extensions()?; | ||
49 | Ok(()) | ||
50 | } | ||
51 | |||
52 | fn verify_installed_extensions() -> Result<()> { | ||
53 | let exts = if cfg!(windows) { | ||
54 | run_with_output(r"cmd.exe /c code.cmd --list-extensions", ".")? | ||
55 | } else { | ||
56 | run_with_output(r"code --list-extensions", ".")? | ||
57 | }; | ||
58 | if !str::from_utf8(&exts.stdout)?.contains("ra-lsp") { | ||
59 | bail!( | ||
60 | "Could not install the Visual Studio Code extension. Please make sure you \ | ||
61 | have at least NodeJS 10.x installed and try again." | ||
62 | ); | ||
63 | } | ||
47 | Ok(()) | 64 | Ok(()) |
48 | } | 65 | } |