summaryrefslogtreecommitdiff
path: root/cli/tools/registry/tar.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-01-24 21:30:08 +0100
committerGitHub <noreply@github.com>2024-01-24 20:30:08 +0000
commit176118a0468c5b4f2117d18271d814000d4752b2 (patch)
tree69c1327c8378b3738616af609a3b4a459e892d6f /cli/tools/registry/tar.rs
parentfb24b004ba598cbc618e6a27b657fc38a5f84af2 (diff)
feat(publish): exclude and include (#22055)
Diffstat (limited to 'cli/tools/registry/tar.rs')
-rw-r--r--cli/tools/registry/tar.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/cli/tools/registry/tar.rs b/cli/tools/registry/tar.rs
index 9bd7f098e..c3fafa4b2 100644
--- a/cli/tools/registry/tar.rs
+++ b/cli/tools/registry/tar.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use bytes::Bytes;
+use deno_config::glob::FilePatterns;
use deno_core::anyhow;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
@@ -13,7 +14,6 @@ use std::path::PathBuf;
use tar::Header;
use crate::util::import_map::ImportMapUnfurler;
-use deno_config::glob::PathOrPatternSet;
use super::diagnostics::PublishDiagnostic;
use super::diagnostics::PublishDiagnosticsCollector;
@@ -37,7 +37,7 @@ pub fn create_gzipped_tarball(
source_cache: &dyn deno_graph::ParsedSourceStore,
diagnostics_collector: &PublishDiagnosticsCollector,
unfurler: &ImportMapUnfurler,
- exclude_patterns: &PathOrPatternSet,
+ file_patterns: Option<FilePatterns>,
) -> Result<PublishableTarball, AnyError> {
let mut tar = TarGzArchive::new();
let mut diagnostics = vec![];
@@ -47,11 +47,13 @@ pub fn create_gzipped_tarball(
while let Some(entry) = iterator.next() {
let entry = entry?;
- if exclude_patterns.matches_path(entry.path()) {
- if entry.file_type().is_dir() {
- iterator.skip_current_dir();
+ if let Some(file_patterns) = &file_patterns {
+ if !file_patterns.matches_path(entry.path()) {
+ if entry.file_type().is_dir() {
+ iterator.skip_current_dir();
+ }
+ continue;
}
- continue;
}
if entry.file_type().is_file() {