From 94fb9ad6b3167e8b8073a09fcf0cb135f383d3d2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 17 Feb 2020 15:33:31 +0100 Subject: Fix extension name --- xtask/src/install.rs | 18 +++++------------- xtask/src/not_bash.rs | 30 +++--------------------------- 2 files changed, 8 insertions(+), 40 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 00bbabce4..91426377f 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs @@ -4,7 +4,7 @@ use std::{env, path::PathBuf, str}; use anyhow::{bail, format_err, Context, Result}; -use crate::not_bash::{ls, pushd, rm, run}; +use crate::not_bash::{pushd, run}; // Latest stable, feel free to send a PR if this lags behind. const REQUIRED_RUST_VERSION: u32 = 41; @@ -99,28 +99,20 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { run!("npm --version").context("`npm` is required to build the VS Code plugin")?; run!("npm install")?; - let vsix_pkg = { - rm("*.vsix")?; - run!("npm run package --scripts-prepend-node-path")?; - ls("*.vsix")?.pop().unwrap() - }; + run!("npm run package --scripts-prepend-node-path")?; let code = find_code(|bin| run!("{} --version", bin).is_ok())?; - run!("{} --install-extension {} --force", code, vsix_pkg.display())?; + run!("{} --install-extension rust-analyzer.vsix --force", code)?; installed_extensions = run!("{} --list-extensions", code; echo = false)?; } else { run!("cmd.exe /c npm --version") .context("`npm` is required to build the VS Code plugin")?; run!("cmd.exe /c npm install")?; - let vsix_pkg = { - rm("*.vsix")?; - run!("cmd.exe /c npm run package")?; - ls("*.vsix")?.pop().unwrap() - }; + run!("cmd.exe /c npm run package")?; let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?; - run!(r"cmd.exe /c {}.cmd --install-extension {} --force", code, vsix_pkg.display())?; + run!(r"cmd.exe /c {}.cmd --install-extension rust-analyzer.vsix --force", code)?; installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; } diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index 3e30e7279..d5577cce9 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs @@ -2,8 +2,6 @@ use std::{ cell::RefCell, env, - ffi::OsStr, - fs, path::{Path, PathBuf}, process::{Command, Stdio}, }; @@ -68,14 +66,11 @@ impl Drop for Pushd { } } -pub fn rm(glob: &str) -> Result<()> { - let cwd = Env::with(|env| env.cwd()); - ls(glob)?.into_iter().try_for_each(|it| fs::remove_file(cwd.join(it)))?; - Ok(()) -} - pub fn rm_rf(path: impl AsRef) -> Result<()> { let path = path.as_ref(); + if !path.exists() { + return Ok(()); + } if path.is_file() { fs2::remove_file(path) } else { @@ -83,25 +78,6 @@ pub fn rm_rf(path: impl AsRef) -> Result<()> { } } -pub fn ls(glob: &str) -> Result> { - let cwd = Env::with(|env| env.cwd()); - let mut res = Vec::new(); - for entry in fs::read_dir(&cwd)? { - let entry = entry?; - if matches(&entry.file_name(), glob) { - let path = entry.path(); - let path = path.strip_prefix(&cwd).unwrap(); - res.push(path.to_path_buf()) - } - } - return Ok(res); - - fn matches(file_name: &OsStr, glob: &str) -> bool { - assert!(glob.starts_with('*')); - file_name.to_string_lossy().ends_with(&glob[1..]) - } -} - #[doc(hidden)] pub fn run_process(cmd: String, echo: bool) -> Result { run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd)) -- cgit v1.2.3