mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Move rm_rf to not-bash
This commit is contained in:
parent
cd956a191f
commit
5acb467894
2 changed files with 23 additions and 9 deletions
|
@ -9,7 +9,7 @@ mod ast_src;
|
|||
|
||||
use anyhow::Context;
|
||||
use std::{
|
||||
env, fs,
|
||||
env,
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
|
@ -17,7 +17,7 @@ use std::{
|
|||
|
||||
use crate::{
|
||||
codegen::Mode,
|
||||
not_bash::{fs2, pushd, run},
|
||||
not_bash::{fs2, pushd, rm_rf, run},
|
||||
};
|
||||
|
||||
pub use anyhow::Result;
|
||||
|
@ -139,7 +139,7 @@ pub fn run_pre_cache() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
fs::remove_file("./target/.rustc_info.json")?;
|
||||
fs2::remove_file("./target/.rustc_info.json")?;
|
||||
let to_delete = ["ra_", "heavy_test"];
|
||||
for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() {
|
||||
for entry in Path::new(dir).read_dir()? {
|
||||
|
@ -153,11 +153,6 @@ pub fn run_pre_cache() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn rm_rf(path: &Path) -> Result<()> {
|
||||
if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) }
|
||||
.with_context(|| format!("failed to remove {:?}", path))
|
||||
}
|
||||
|
||||
pub fn run_release(dry_run: bool) -> Result<()> {
|
||||
if !dry_run {
|
||||
run!("git switch release")?;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
env,
|
||||
ffi::OsStr,
|
||||
fs,
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,16 @@ pub mod fs2 {
|
|||
fs::copy(from, to)
|
||||
.with_context(|| format!("Failed to copy {} to {}", from.display(), to.display()))
|
||||
}
|
||||
|
||||
pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<()> {
|
||||
let path = path.as_ref();
|
||||
fs::remove_file(path).with_context(|| format!("Failed to remove file {}", path.display()))
|
||||
}
|
||||
|
||||
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> Result<()> {
|
||||
let path = path.as_ref();
|
||||
fs::remove_dir_all(path).with_context(|| format!("Failed to remove dir {}", path.display()))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! _run {
|
||||
|
@ -64,6 +74,15 @@ pub fn rm(glob: &str) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> {
|
||||
let path = path.as_ref();
|
||||
if path.is_file() {
|
||||
fs2::remove_file(path)
|
||||
} else {
|
||||
fs2::remove_dir_all(path)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ls(glob: &str) -> Result<Vec<PathBuf>> {
|
||||
let cwd = Env::with(|env| env.cwd());
|
||||
let mut res = Vec::new();
|
||||
|
|
Loading…
Reference in a new issue