mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
fix: empty include in config file excludes all (#20404)
This commit is contained in:
parent
14522fc628
commit
17276a1df9
9 changed files with 43 additions and 39 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1049,9 +1049,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.2.4"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc0c89c37b55d33bdd3374fddb9e6bf74dd7d071d1217d1ef3ab7d09bcefb6d3"
|
||||
checksum = "ee6f80798a5460656fbbbcdbe6e7700878a6777739195a205e97a8e5fcd00baf"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deno_semver",
|
||||
|
|
|
@ -47,7 +47,7 @@ winres.workspace = true
|
|||
[dependencies]
|
||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_cache_dir = "=0.6.0"
|
||||
deno_config = "=0.2.4"
|
||||
deno_config = "=0.3.0"
|
||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = "=0.66.0"
|
||||
deno_emit = "=0.27.0"
|
||||
|
|
|
@ -1398,20 +1398,18 @@ fn resolve_files(
|
|||
let mut result = maybe_files_config.unwrap_or_default();
|
||||
if let Some(file_flags) = maybe_file_flags {
|
||||
if !file_flags.include.is_empty() {
|
||||
result.include = file_flags.include;
|
||||
result.include = Some(file_flags.include);
|
||||
}
|
||||
if !file_flags.ignore.is_empty() {
|
||||
result.exclude = file_flags.ignore;
|
||||
}
|
||||
}
|
||||
// Now expand globs if there are any
|
||||
if !result.include.is_empty() {
|
||||
result.include = expand_globs(result.include)?;
|
||||
}
|
||||
|
||||
if !result.exclude.is_empty() {
|
||||
result.exclude = expand_globs(result.exclude)?;
|
||||
}
|
||||
result.include = match result.include {
|
||||
Some(include) => Some(expand_globs(include)?),
|
||||
None => None,
|
||||
};
|
||||
result.exclude = expand_globs(result.exclude)?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
@ -1624,7 +1622,7 @@ mod test {
|
|||
let temp_dir_path = temp_dir.path().as_path();
|
||||
let error = resolve_files(
|
||||
Some(FilesConfig {
|
||||
include: vec![temp_dir_path.join("data/**********.ts")],
|
||||
include: Some(vec![temp_dir_path.join("data/**********.ts")]),
|
||||
exclude: vec![],
|
||||
}),
|
||||
None,
|
||||
|
@ -1634,12 +1632,12 @@ mod test {
|
|||
|
||||
let resolved_files = resolve_files(
|
||||
Some(FilesConfig {
|
||||
include: vec![
|
||||
include: Some(vec![
|
||||
temp_dir_path.join("data/test1.?s"),
|
||||
temp_dir_path.join("nested/foo/*.ts"),
|
||||
temp_dir_path.join("nested/fizz/*.ts"),
|
||||
temp_dir_path.join("pages/[id].ts"),
|
||||
],
|
||||
]),
|
||||
exclude: vec![temp_dir_path.join("nested/**/*bazz.ts")],
|
||||
}),
|
||||
None,
|
||||
|
@ -1648,7 +1646,7 @@ mod test {
|
|||
|
||||
assert_eq!(
|
||||
resolved_files.include,
|
||||
vec![
|
||||
Some(vec![
|
||||
temp_dir_path.join("data/test1.js"),
|
||||
temp_dir_path.join("data/test1.ts"),
|
||||
temp_dir_path.join("nested/foo/bar.ts"),
|
||||
|
@ -1660,7 +1658,7 @@ mod test {
|
|||
temp_dir_path.join("nested/fizz/fizz.ts"),
|
||||
temp_dir_path.join("nested/fizz/foo.ts"),
|
||||
temp_dir_path.join("pages/[id].ts"),
|
||||
]
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
resolved_files.exclude,
|
||||
|
|
|
@ -429,7 +429,9 @@ pub async fn run_benchmarks_with_watch(
|
|||
let bench_options = cli_options.resolve_bench_options(bench_flags)?;
|
||||
|
||||
let _ = sender.send(cli_options.watch_paths());
|
||||
let _ = sender.send(bench_options.files.include.clone());
|
||||
if let Some(include) = &bench_options.files.include {
|
||||
let _ = sender.send(include.clone());
|
||||
}
|
||||
|
||||
let graph_kind = cli_options.type_check_mode().as_graph_kind();
|
||||
let module_graph_builder = factory.module_graph_builder().await?;
|
||||
|
|
|
@ -573,7 +573,11 @@ fn collect_coverages(
|
|||
.ignore_node_modules()
|
||||
.ignore_vendor_folder()
|
||||
.add_ignore_paths(&files.ignore)
|
||||
.collect_files(&files.include)?;
|
||||
.collect_files(if files.include.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(&files.include)
|
||||
})?;
|
||||
|
||||
for file_path in file_paths {
|
||||
let json = fs::read_to_string(file_path.as_path())?;
|
||||
|
|
|
@ -153,7 +153,7 @@ fn collect_fmt_files(files: &FilesConfig) -> Result<Vec<PathBuf>, AnyError> {
|
|||
.ignore_node_modules()
|
||||
.ignore_vendor_folder()
|
||||
.add_ignore_paths(&files.exclude)
|
||||
.collect_files(&files.include)
|
||||
.collect_files(files.include.as_deref())
|
||||
}
|
||||
|
||||
/// Formats markdown (using <https://github.com/dprint/dprint-plugin-markdown>) and its code blocks
|
||||
|
|
|
@ -200,7 +200,7 @@ fn collect_lint_files(files: &FilesConfig) -> Result<Vec<PathBuf>, AnyError> {
|
|||
.ignore_node_modules()
|
||||
.ignore_vendor_folder()
|
||||
.add_ignore_paths(&files.exclude)
|
||||
.collect_files(&files.include)
|
||||
.collect_files(files.include.as_deref())
|
||||
}
|
||||
|
||||
pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
|
||||
|
|
|
@ -1199,7 +1199,9 @@ pub async fn run_tests_with_watch(
|
|||
let test_options = cli_options.resolve_test_options(test_flags)?;
|
||||
|
||||
let _ = sender.send(cli_options.watch_paths());
|
||||
let _ = sender.send(test_options.files.include.clone());
|
||||
if let Some(include) = &test_options.files.include {
|
||||
let _ = sender.send(include.clone());
|
||||
}
|
||||
|
||||
let graph_kind = cli_options.type_check_mode().as_graph_kind();
|
||||
let log_level = cli_options.log_level();
|
||||
|
|
|
@ -239,14 +239,13 @@ impl<TFilter: Fn(&Path) -> bool> FileCollector<TFilter> {
|
|||
|
||||
pub fn collect_files(
|
||||
&self,
|
||||
files: &[PathBuf],
|
||||
files: Option<&[PathBuf]>,
|
||||
) -> Result<Vec<PathBuf>, AnyError> {
|
||||
let mut target_files = Vec::new();
|
||||
let files = if files.is_empty() {
|
||||
// collect files in the current directory when empty
|
||||
Cow::Owned(vec![PathBuf::from(".")])
|
||||
} else {
|
||||
let files = if let Some(files) = files {
|
||||
Cow::Borrowed(files)
|
||||
} else {
|
||||
Cow::Owned(vec![PathBuf::from(".")])
|
||||
};
|
||||
for file in files.iter() {
|
||||
if let Ok(file) = canonicalize_path(file) {
|
||||
|
@ -312,11 +311,10 @@ pub fn collect_specifiers(
|
|||
.ignore_vendor_folder();
|
||||
|
||||
let root_path = current_dir()?;
|
||||
let include_files = if files.include.is_empty() {
|
||||
// collect files in the current directory when empty
|
||||
Cow::Owned(vec![root_path.clone()])
|
||||
let include_files = if let Some(include) = &files.include {
|
||||
Cow::Borrowed(include)
|
||||
} else {
|
||||
Cow::Borrowed(&files.include)
|
||||
Cow::Owned(vec![root_path.clone()])
|
||||
};
|
||||
for path in include_files.iter() {
|
||||
let path = path.to_string_lossy();
|
||||
|
@ -336,7 +334,7 @@ pub fn collect_specifiers(
|
|||
};
|
||||
let p = normalize_path(p);
|
||||
if p.is_dir() {
|
||||
let test_files = file_collector.collect_files(&[p])?;
|
||||
let test_files = file_collector.collect_files(Some(&[p]))?;
|
||||
let mut test_files_as_urls = test_files
|
||||
.iter()
|
||||
.map(|f| ModuleSpecifier::from_file_path(f).unwrap())
|
||||
|
@ -776,7 +774,7 @@ mod tests {
|
|||
.add_ignore_paths(&[ignore_dir_path.to_path_buf()]);
|
||||
|
||||
let result = file_collector
|
||||
.collect_files(&[root_dir_path.to_path_buf()])
|
||||
.collect_files(Some(&[root_dir_path.to_path_buf()]))
|
||||
.unwrap();
|
||||
let expected = [
|
||||
"README.md",
|
||||
|
@ -803,7 +801,7 @@ mod tests {
|
|||
.ignore_node_modules()
|
||||
.ignore_vendor_folder();
|
||||
let result = file_collector
|
||||
.collect_files(&[root_dir_path.to_path_buf()])
|
||||
.collect_files(Some(&[root_dir_path.to_path_buf()]))
|
||||
.unwrap();
|
||||
let expected = [
|
||||
"README.md",
|
||||
|
@ -823,10 +821,10 @@ mod tests {
|
|||
|
||||
// test opting out of ignoring by specifying the dir
|
||||
let result = file_collector
|
||||
.collect_files(&[
|
||||
.collect_files(Some(&[
|
||||
root_dir_path.to_path_buf(),
|
||||
root_dir_path.to_path_buf().join("child/node_modules/"),
|
||||
])
|
||||
]))
|
||||
.unwrap();
|
||||
let expected = [
|
||||
"README.md",
|
||||
|
@ -894,11 +892,11 @@ mod tests {
|
|||
|
||||
let result = collect_specifiers(
|
||||
&FilesConfig {
|
||||
include: vec![
|
||||
include: Some(vec![
|
||||
PathBuf::from("http://localhost:8080"),
|
||||
root_dir_path.to_path_buf(),
|
||||
PathBuf::from("https://localhost:8080".to_string()),
|
||||
],
|
||||
]),
|
||||
exclude: vec![ignore_dir_path.to_path_buf()],
|
||||
},
|
||||
predicate,
|
||||
|
@ -933,11 +931,11 @@ mod tests {
|
|||
};
|
||||
let result = collect_specifiers(
|
||||
&FilesConfig {
|
||||
include: vec![PathBuf::from(format!(
|
||||
include: Some(vec![PathBuf::from(format!(
|
||||
"{}{}",
|
||||
scheme,
|
||||
root_dir_path.join("child").to_string().replace('\\', "/")
|
||||
))],
|
||||
))]),
|
||||
exclude: vec![],
|
||||
},
|
||||
predicate,
|
||||
|
|
Loading…
Reference in a new issue