File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ use std::{
1717
1818use crate :: {
1919 codegen:: Mode ,
20- not_bash:: { pushd, run} ,
20+ not_bash:: { fs2 , pushd, run} ,
2121} ;
2222
2323pub use anyhow:: Result ;
@@ -167,11 +167,11 @@ pub fn run_release(dry_run: bool) -> Result<()> {
167167 }
168168
169169 let website_root = project_root ( ) . join ( "../rust-analyzer.github.io" ) ;
170- let changelog_dir = website_root. join ( "/thisweek/_posts" ) ;
170+ let changelog_dir = website_root. join ( ". /thisweek/_posts" ) ;
171171
172172 let today = run ! ( "date --iso" ) ?;
173173 let commit = run ! ( "git rev-parse HEAD" ) ?;
174- let changelog_n = fs :: read_dir ( changelog_dir. as_path ( ) ) ?. count ( ) ;
174+ let changelog_n = fs2 :: read_dir ( changelog_dir. as_path ( ) ) ?. count ( ) ;
175175
176176 let contents = format ! (
177177 "\
@@ -194,9 +194,9 @@ Release: release:{}[]
194194 ) ;
195195
196196 let path = changelog_dir. join ( format ! ( "{}-changelog-{}.adoc" , today, changelog_n) ) ;
197- fs :: write ( & path, & contents) ?;
197+ fs2 :: write ( & path, & contents) ?;
198198
199- fs :: copy ( project_root ( ) . join ( "./docs/user/readme.adoc" ) , website_root. join ( "manual.adoc" ) ) ?;
199+ fs2 :: copy ( project_root ( ) . join ( "./docs/user/readme.adoc" ) , website_root. join ( "manual.adoc" ) ) ?;
200200
201201 Ok ( ( ) )
202202}
Original file line number Diff line number Diff line change @@ -10,6 +10,29 @@ use std::{
1010
1111use anyhow:: { bail, Context , Result } ;
1212
13+ pub mod fs2 {
14+ use std:: { fs, path:: Path } ;
15+
16+ use anyhow:: { Context , Result } ;
17+
18+ pub fn read_dir < P : AsRef < Path > > ( path : P ) -> Result < fs:: ReadDir > {
19+ let path = path. as_ref ( ) ;
20+ fs:: read_dir ( path) . with_context ( || format ! ( "Failed to read {}" , path. display( ) ) )
21+ }
22+
23+ pub fn write < P : AsRef < Path > , C : AsRef < [ u8 ] > > ( path : P , contents : C ) -> Result < ( ) > {
24+ let path = path. as_ref ( ) ;
25+ fs:: write ( path, contents) . with_context ( || format ! ( "Failed to write {}" , path. display( ) ) )
26+ }
27+
28+ pub fn copy < P : AsRef < Path > , Q : AsRef < Path > > ( from : P , to : Q ) -> Result < u64 > {
29+ let from = from. as_ref ( ) ;
30+ let to = to. as_ref ( ) ;
31+ fs:: copy ( from, to)
32+ . with_context ( || format ! ( "Failed to copy {} to {}" , from. display( ) , to. display( ) ) )
33+ }
34+ }
35+
1336macro_rules! _run {
1437 ( $( $expr: expr) ,* ) => {
1538 run!( $( $expr) ,* ; echo = true )
You can’t perform that action at this time.
0 commit comments