@@ -2,11 +2,11 @@ use std::error::Error;
22use std:: path:: { Path , PathBuf } ;
33use yaml_rust:: { Yaml , YamlEmitter , YamlLoader } ;
44
5- /// List of directories containing files to expand. The first tuple element is the source
6- /// directory , while the second tuple element is the destination directory .
5+ /// List of files to expand. The first tuple element is the source
6+ /// file , while the second tuple element is the destination file .
77#[ rustfmt:: skip]
88static TO_EXPAND : & [ ( & str , & str ) ] = & [
9- ( "src/ci/github-actions" , ".github/workflows" ) ,
9+ ( "src/ci/github-actions/ci.yml " , ".github/workflows/ci.yml " ) ,
1010] ;
1111
1212/// Name of a special key that will be removed from all the maps in expanded configuration files.
@@ -62,27 +62,20 @@ impl App {
6262 fn run ( & self ) -> Result < ( ) , Box < dyn Error > > {
6363 for ( source, dest) in TO_EXPAND {
6464 let source = self . base . join ( source) ;
65- let dest = self . base . join ( dest) ;
66- for entry in std:: fs:: read_dir ( & source) ? {
67- let path = entry?. path ( ) ;
68- if !path. is_file ( ) || path. extension ( ) . and_then ( |e| e. to_str ( ) ) != Some ( "yml" ) {
69- continue ;
70- }
71-
72- let dest_path = dest. join ( path. file_name ( ) . unwrap ( ) ) ;
73- self . expand ( & path, & dest_path) . with_context ( || match self . mode {
74- Mode :: Generate => format ! (
75- "failed to expand {} into {}" ,
76- self . path( & path) ,
77- self . path( & dest_path)
78- ) ,
79- Mode :: Check => format ! (
80- "{} is not up to date; please run \
65+ let dest_path = self . base . join ( dest) ;
66+
67+ self . expand ( & source, & dest_path) . with_context ( || match self . mode {
68+ Mode :: Generate => format ! (
69+ "failed to expand {} into {}" ,
70+ self . path( & source) ,
71+ self . path( & dest_path)
72+ ) ,
73+ Mode :: Check => format ! (
74+ "{} is not up to date; please run \
8175 `x.py run src/tools/expand-yaml-anchors`.",
82- self . path( & dest_path)
83- ) ,
84- } ) ?;
85- }
76+ self . path( & dest_path)
77+ ) ,
78+ } ) ?;
8679 }
8780 Ok ( ( ) )
8881 }
0 commit comments