mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Add fs2 module for better error messages
This commit is contained in:
parent
705f8820c9
commit
3f675179e5
2 changed files with 28 additions and 5 deletions
|
@ -17,7 +17,7 @@ use std::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
codegen::Mode,
|
codegen::Mode,
|
||||||
not_bash::{pushd, run},
|
not_bash::{fs2, pushd, run},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use anyhow::Result;
|
pub use anyhow::Result;
|
||||||
|
@ -167,11 +167,11 @@ pub fn run_release(dry_run: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let website_root = project_root().join("../rust-analyzer.github.io");
|
let website_root = project_root().join("../rust-analyzer.github.io");
|
||||||
let changelog_dir = website_root.join("/thisweek/_posts");
|
let changelog_dir = website_root.join("./thisweek/_posts");
|
||||||
|
|
||||||
let today = run!("date --iso")?;
|
let today = run!("date --iso")?;
|
||||||
let commit = run!("git rev-parse HEAD")?;
|
let commit = run!("git rev-parse HEAD")?;
|
||||||
let changelog_n = fs::read_dir(changelog_dir.as_path())?.count();
|
let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count();
|
||||||
|
|
||||||
let contents = format!(
|
let contents = format!(
|
||||||
"\
|
"\
|
||||||
|
@ -194,9 +194,9 @@ Release: release:{}[]
|
||||||
);
|
);
|
||||||
|
|
||||||
let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
|
let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
|
||||||
fs::write(&path, &contents)?;
|
fs2::write(&path, &contents)?;
|
||||||
|
|
||||||
fs::copy(project_root().join("./docs/user/readme.adoc"), website_root.join("manual.adoc"))?;
|
fs2::copy(project_root().join("./docs/user/readme.adoc"), website_root.join("manual.adoc"))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,29 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
|
|
||||||
|
pub mod fs2 {
|
||||||
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
|
pub fn read_dir<P: AsRef<Path>>(path: P) -> Result<fs::ReadDir> {
|
||||||
|
let path = path.as_ref();
|
||||||
|
fs::read_dir(path).with_context(|| format!("Failed to read {}", path.display()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> {
|
||||||
|
let path = path.as_ref();
|
||||||
|
fs::write(path, contents).with_context(|| format!("Failed to write {}", path.display()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
|
||||||
|
let from = from.as_ref();
|
||||||
|
let to = to.as_ref();
|
||||||
|
fs::copy(from, to)
|
||||||
|
.with_context(|| format!("Failed to copy {} to {}", from.display(), to.display()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! _run {
|
macro_rules! _run {
|
||||||
($($expr:expr),*) => {
|
($($expr:expr),*) => {
|
||||||
run!($($expr),*; echo = true)
|
run!($($expr),*; echo = true)
|
||||||
|
|
Loading…
Reference in a new issue