aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/lib.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 16b06b853..b19985fb2 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -38,19 +38,13 @@ pub fn rust_files() -> impl Iterator<Item = PathBuf> {
38 rust_files_in(&project_root().join("crates")) 38 rust_files_in(&project_root().join("crates"))
39} 39}
40 40
41pub fn rust_files_in(path: &Path) -> impl Iterator<Item = PathBuf> { 41pub fn cargo_files() -> impl Iterator<Item = PathBuf> {
42 let iter = WalkDir::new(path); 42 files_in(&project_root(), "toml")
43 return iter 43 .filter(|path| path.file_name().map(|it| it == "Cargo.toml").unwrap_or(false))
44 .into_iter() 44}
45 .filter_entry(|e| !is_hidden(e))
46 .map(|e| e.unwrap())
47 .filter(|e| !e.file_type().is_dir())
48 .map(|e| e.into_path())
49 .filter(|path| path.extension().map(|it| it == "rs").unwrap_or(false));
50 45
51 fn is_hidden(entry: &DirEntry) -> bool { 46pub fn rust_files_in(path: &Path) -> impl Iterator<Item = PathBuf> {
52 entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false) 47 files_in(path, "rs")
53 }
54} 48}
55 49
56pub fn run_rustfmt(mode: Mode) -> Result<()> { 50pub fn run_rustfmt(mode: Mode) -> Result<()> {
@@ -120,3 +114,18 @@ fn date_iso() -> Result<String> {
120fn is_release_tag(tag: &str) -> bool { 114fn is_release_tag(tag: &str) -> bool {
121 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) 115 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit())
122} 116}
117
118fn files_in(path: &Path, ext: &'static str) -> impl Iterator<Item = PathBuf> {
119 let iter = WalkDir::new(path);
120 return iter
121 .into_iter()
122 .filter_entry(|e| !is_hidden(e))
123 .map(|e| e.unwrap())
124 .filter(|e| !e.file_type().is_dir())
125 .map(|e| e.into_path())
126 .filter(move |path| path.extension().map(|it| it == ext).unwrap_or(false));
127
128 fn is_hidden(entry: &DirEntry) -> bool {
129 entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false)
130 }
131}