feat: ignore node_modules and .git folders when collecting files everywhere (#16862)

We currently only do this for fmt. This makes it so they're excluded by
default, but you can still opt into these directories by explicitly
specifying them.
This commit is contained in:
David Sherret 2022-12-07 13:10:10 -05:00 committed by GitHub
parent f4385866f8
commit 9c1ab39e19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 215 additions and 111 deletions

View file

@ -6,7 +6,7 @@ use crate::colors;
use crate::emit::get_source_hash;
use crate::proc_state::ProcState;
use crate::tools::fmt::format_json;
use crate::util::fs::collect_files;
use crate::util::fs::FileCollector;
use crate::util::text_encoding::source_map_from_code;
use deno_ast::MediaType;
@ -558,9 +558,13 @@ fn collect_coverages(
ignore: Vec<PathBuf>,
) -> Result<Vec<ScriptCoverage>, AnyError> {
let mut coverages: Vec<ScriptCoverage> = Vec::new();
let file_paths = collect_files(&files, &ignore, |file_path| {
let file_paths = FileCollector::new(|file_path| {
file_path.extension().map_or(false, |ext| ext == "json")
})?;
})
.ignore_git_folder()
.ignore_node_modules()
.add_ignore_paths(&ignore)
.collect_files(&files)?;
for file_path in file_paths {
let json = fs::read_to_string(file_path.as_path())?;