diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-03-07 20:16:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 20:16:32 -0500 |
commit | 2dfc0aca7c6a04d54fe6f9a73be70fc4c591d552 (patch) | |
tree | 58fb01c46364e4888097e7135b2f829f38ce990c /cli/tools/bench | |
parent | 2ed984ba3aa638c3f088ac1edc5c779c7d9195d1 (diff) |
fix(publish): make include and exclude work (#22720)
1. Stops `deno publish` using some custom include/exclude behaviour from
other sub commands
2. Takes ancestor directories into account when resolving gitignore
3. Backards compatible change that adds ability to unexclude an exclude
by using a negated glob at a more specific level for all sub commands
(see https://github.com/denoland/deno_config/pull/44).
Diffstat (limited to 'cli/tools/bench')
-rw-r--r-- | cli/tools/bench/mod.rs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/cli/tools/bench/mod.rs b/cli/tools/bench/mod.rs index 43b7103cd..b554f7349 100644 --- a/cli/tools/bench/mod.rs +++ b/cli/tools/bench/mod.rs @@ -14,12 +14,12 @@ use crate::tools::test::format_test_error; use crate::tools::test::TestFilter; use crate::util::file_watcher; use crate::util::fs::collect_specifiers; +use crate::util::fs::WalkEntry; use crate::util::path::is_script_ext; +use crate::util::path::matches_pattern_or_exact_path; use crate::version::get_user_agent; use crate::worker::CliMainWorkerFactory; -use deno_config::glob::FilePatterns; -use deno_config::glob::PathOrPattern; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::error::JsError; @@ -394,25 +394,16 @@ async fn bench_specifiers( } /// Checks if the path has a basename and extension Deno supports for benches. -fn is_supported_bench_path(path: &Path, patterns: &FilePatterns) -> bool { - if !is_script_ext(path) { +fn is_supported_bench_path(entry: WalkEntry) -> bool { + if !is_script_ext(entry.path) { false - } else if has_supported_bench_path_name(path) { + } else if has_supported_bench_path_name(entry.path) { true - } else { + } else if let Some(include) = &entry.patterns.include { // allow someone to explicitly specify a path - let matches_exact_path_or_pattern = patterns - .include - .as_ref() - .map(|p| { - p.inner().iter().any(|p| match p { - PathOrPattern::Path(p) => p == path, - PathOrPattern::RemoteUrl(_) => true, - PathOrPattern::Pattern(p) => p.matches_path(path), - }) - }) - .unwrap_or(false); - matches_exact_path_or_pattern + matches_pattern_or_exact_path(include, entry.path) + } else { + false } } |