Check installed extension
This commit is contained in:
parent
bbaf750b10
commit
cb60416cb5
@ -2,7 +2,7 @@
|
||||
fs,
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
process::{Command, Output, Stdio},
|
||||
io::{Error, ErrorKind}
|
||||
};
|
||||
|
||||
@ -80,15 +80,14 @@ pub fn project_root() -> PathBuf {
|
||||
}
|
||||
|
||||
pub fn run(cmdline: &str, dir: &str) -> Result<()> {
|
||||
eprintln!("\nwill run: {}", cmdline);
|
||||
let project_dir = project_root().join(dir);
|
||||
let mut args = cmdline.split_whitespace();
|
||||
let exec = args.next().unwrap();
|
||||
let status = Command::new(exec).args(args).current_dir(project_dir).status()?;
|
||||
if !status.success() {
|
||||
bail!("`{}` exited with {}", cmdline, status);
|
||||
}
|
||||
Ok(())
|
||||
do_run(cmdline, dir, |c| {
|
||||
c.stdout(Stdio::inherit());
|
||||
})
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
pub fn run_with_output(cmdline: &str, dir: &str) -> Result<Output> {
|
||||
do_run(cmdline, dir, |_| {})
|
||||
}
|
||||
|
||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||
@ -175,6 +174,23 @@ fn install_tests(tests: &HashMap<String, Test>, into: &str, mode: Mode) -> Resul
|
||||
install_tests(&tests.err, ERR_INLINE_TESTS_DIR, mode)
|
||||
}
|
||||
|
||||
fn do_run<F>(cmdline: &str, dir: &str, mut f: F) -> Result<Output>
|
||||
where
|
||||
F: FnMut(&mut Command),
|
||||
{
|
||||
eprintln!("\nwill run: {}", cmdline);
|
||||
let proj_dir = project_root().join(dir);
|
||||
let mut args = cmdline.split_whitespace();
|
||||
let exec = args.next().unwrap();
|
||||
let mut cmd = Command::new(exec);
|
||||
f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit()));
|
||||
let output = cmd.output()?;
|
||||
if !output.status.success() {
|
||||
bail!("`{}` exited with {}", cmdline, output.status);
|
||||
}
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct Tests {
|
||||
pub ok: HashMap<String, Test>,
|
||||
|
@ -1,7 +1,8 @@
|
||||
use clap::{App, SubCommand};
|
||||
|
||||
use core::str;
|
||||
use failure::bail;
|
||||
use tools::{
|
||||
generate, gen_tests, install_format_hook, run, run_rustfmt,
|
||||
generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt,
|
||||
Overwrite, Result, run_fuzzer,
|
||||
};
|
||||
|
||||
@ -44,5 +45,21 @@ fn install_code_extension() -> Result<()> {
|
||||
} else {
|
||||
run(r"code --install-extension ./ra-lsp-0.0.1.vsix --force", "./editors/code")?;
|
||||
}
|
||||
verify_installed_extensions()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_installed_extensions() -> Result<()> {
|
||||
let exts = if cfg!(windows) {
|
||||
run_with_output(r"cmd.exe /c code.cmd --list-extensions", ".")?
|
||||
} else {
|
||||
run_with_output(r"code --list-extensions", ".")?
|
||||
};
|
||||
if !str::from_utf8(&exts.stdout)?.contains("ra-lsp") {
|
||||
bail!(
|
||||
"Could not install the Visual Studio Code extension. Please make sure you \
|
||||
have at least NodeJS 10.x installed and try again."
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user