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/lsp/documents.rs | |
| 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/lsp/documents.rs')
| -rw-r--r-- | cli/lsp/documents.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index b825bc020..7912dad78 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -1341,11 +1341,12 @@ impl Documents { .inner() .iter() .map(|p| match p { - PathOrPattern::Path(p) => { - Cow::Owned(p.to_string_lossy().to_string()) + PathOrPattern::Path(p) => p.to_string_lossy(), + PathOrPattern::NegatedPath(p) => { + Cow::Owned(format!("!{}", p.to_string_lossy())) } PathOrPattern::RemoteUrl(p) => Cow::Borrowed(p.as_str()), - PathOrPattern::Pattern(p) => Cow::Borrowed(p.as_str()), + PathOrPattern::Pattern(p) => p.as_str(), }) .collect::<Vec<_>>(); // ensure these are sorted so the hashing is deterministic @@ -2061,8 +2062,13 @@ impl Iterator for PreloadDocumentFinder { if let Ok(entry) = entry { let path = entry.path(); if let Ok(file_type) = entry.file_type() { - if file_patterns.matches_path(&path) { - if file_type.is_dir() && is_discoverable_dir(&path) { + let is_dir = file_type.is_dir(); + let path_kind = match is_dir { + true => deno_config::glob::PathKind::Directory, + false => deno_config::glob::PathKind::File, + }; + if file_patterns.matches_path(&path, path_kind) { + if is_dir && is_discoverable_dir(&path) { self.pending_entries.push_back(PendingEntry::Dir( path.to_path_buf(), file_patterns.clone(), @@ -2354,7 +2360,7 @@ console.log(b, "hello deno"); file_patterns: FilePatterns { base: temp_dir.path().to_path_buf(), include: Some( - PathOrPatternSet::from_relative_path_or_patterns( + PathOrPatternSet::from_include_relative_path_or_patterns( temp_dir.path().as_path(), &[ "root1".to_string(), @@ -2415,7 +2421,7 @@ console.log(b, "hello deno"); file_patterns: FilePatterns { base: temp_dir.path().to_path_buf(), include: Default::default(), - exclude: PathOrPatternSet::from_relative_path_or_patterns( + exclude: PathOrPatternSet::from_exclude_relative_path_or_patterns( temp_dir.path().as_path(), &[ "root1".to_string(), |
