diff --git a/Cargo.lock b/Cargo.lock index e43bfcc949..32454d5163 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1360,9 +1360,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.30.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e287a8ab3552cf3ef8fc41b2bd7cc041c5e8e1a76de3aeb26e804b570bab37d7" +checksum = "9657dbcc5210407fd9a1b1571310f2fe25c6dd6be2195c964d19f43d70045a95" dependencies = [ "anyhow", "deno_package_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index c3fc704f16..06384f479c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -65,7 +65,7 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = { version = "=0.30.0", features = ["workspace", "sync"] } +deno_config = { version = "=0.30.1", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.146.0", features = ["html", "syntect"] } deno_emit = "=0.44.0" diff --git a/cli/graph_container.rs b/cli/graph_container.rs index cf913464fd..9f71045c69 100644 --- a/cli/graph_container.rs +++ b/cli/graph_container.rs @@ -3,15 +3,18 @@ use std::sync::Arc; use deno_ast::ModuleSpecifier; +use deno_config::glob::FilePatterns; +use deno_config::glob::PathOrPatternSet; use deno_core::error::AnyError; use deno_core::parking_lot::RwLock; -use deno_core::resolve_url_or_path; use deno_graph::ModuleGraph; use deno_runtime::colors; use deno_runtime::deno_permissions::PermissionsContainer; use crate::args::CliOptions; use crate::module_loader::ModuleLoadPreparer; +use crate::util::fs::collect_specifiers; +use crate::util::path::is_script_ext; pub trait ModuleGraphContainer: Clone + 'static { /// Acquires a permit to modify the module graph without other code @@ -99,24 +102,20 @@ impl MainModuleGraphContainer { files: &[String], ) -> Result, AnyError> { let excludes = self.cli_options.workspace().resolve_config_excludes()?; - Ok( - files - .iter() - .filter_map(|file| { - let file_url = - resolve_url_or_path(file, self.cli_options.initial_cwd()).ok()?; - if file_url.scheme() != "file" { - return Some(file_url); - } - // ignore local files that match any of files listed in `exclude` option - let file_path = file_url.to_file_path().ok()?; - if excludes.matches_path(&file_path) { - None - } else { - Some(file_url) - } - }) - .collect::>(), + let include_patterns = + PathOrPatternSet::from_include_relative_path_or_patterns( + self.cli_options.initial_cwd(), + files, + )?; + let file_patterns = FilePatterns { + base: self.cli_options.initial_cwd().to_path_buf(), + include: Some(include_patterns), + exclude: excludes, + }; + collect_specifiers( + file_patterns, + self.cli_options.vendor_dir_path().map(ToOwned::to_owned), + |e| is_script_ext(e.path), ) } } diff --git a/tests/specs/cache/globbing/__test__.jsonc b/tests/specs/cache/globbing/__test__.jsonc new file mode 100644 index 0000000000..9bf210bb41 --- /dev/null +++ b/tests/specs/cache/globbing/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "cache *.ts", + "output": "Download http://localhost:4545/echo.ts\n", + "exitCode": 0 +} diff --git a/tests/specs/cache/globbing/excluded.tsx b/tests/specs/cache/globbing/excluded.tsx new file mode 100644 index 0000000000..b21a330c79 --- /dev/null +++ b/tests/specs/cache/globbing/excluded.tsx @@ -0,0 +1 @@ +import "http://localhost:4545/non-existent.ts"; diff --git a/tests/specs/cache/globbing/main.ts b/tests/specs/cache/globbing/main.ts new file mode 100644 index 0000000000..fe49641188 --- /dev/null +++ b/tests/specs/cache/globbing/main.ts @@ -0,0 +1 @@ +import "http://localhost:4545/echo.ts"; diff --git a/tests/specs/check/globbing/__test__.jsonc b/tests/specs/check/globbing/__test__.jsonc new file mode 100644 index 0000000000..92d9f4d807 --- /dev/null +++ b/tests/specs/check/globbing/__test__.jsonc @@ -0,0 +1,24 @@ +{ + "tests": { + "star": { + "args": "check *.ts", + "output": "Check [WILDLINE]main.ts\n", + "exitCode": 0 + }, + "star_not_found": { + "args": "check *.js", + "output": "Warning No matching files found.\n", + "exitCode": 0 + }, + "glob_star": { + "args": "check **/*.ts", + "output": "Check [WILDLINE]main.ts\nCheck [WILDLINE]sub_dir/main.ts\nerror: TS2322[WILDCARD]", + "exitCode": 1 + }, + "sub_dir": { + "args": "check sub_dir", + "output": "Check [WILDLINE]sub_dir/main.ts\nerror: TS2322[WILDCARD]", + "exitCode": 1 + } + } +} diff --git a/tests/specs/check/globbing/excluded.tsx b/tests/specs/check/globbing/excluded.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/specs/check/globbing/main.ts b/tests/specs/check/globbing/main.ts new file mode 100644 index 0000000000..efa57a7ed3 --- /dev/null +++ b/tests/specs/check/globbing/main.ts @@ -0,0 +1 @@ +console.log("globbing_support_done"); diff --git a/tests/specs/check/globbing/sub_dir/main.ts b/tests/specs/check/globbing/sub_dir/main.ts new file mode 100644 index 0000000000..4f4c3ce9c2 --- /dev/null +++ b/tests/specs/check/globbing/sub_dir/main.ts @@ -0,0 +1 @@ +const value: number = "";