summaryrefslogtreecommitdiff
path: root/cli/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/fs.rs')
-rw-r--r--cli/fs.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli/fs.rs b/cli/fs.rs
index 8d3a31bb5..521b996ac 100644
--- a/cli/fs.rs
+++ b/cli/fs.rs
@@ -9,6 +9,7 @@ use deno_core::ErrBox;
use rand;
use rand::Rng;
use url::Url;
+use walkdir::WalkDir;
#[cfg(unix)]
use nix::unistd::{chown as unix_chown, Gid, Uid};
@@ -188,3 +189,17 @@ mod tests {
assert_eq!(resolve_from_cwd(expected).unwrap(), expected);
}
}
+
+pub fn files_in_subtree<F>(root: PathBuf, filter: F) -> Vec<PathBuf>
+where
+ F: Fn(&Path) -> bool,
+{
+ assert!(root.is_dir());
+
+ WalkDir::new(root)
+ .into_iter()
+ .filter_map(|e| e.ok())
+ .map(|e| e.path().to_owned())
+ .filter(|p| if p.is_dir() { false } else { filter(&p) })
+ .collect()
+}