mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat: glob and directory support for deno check
and deno cache
cli arg paths (#25001)
Closes #24668 Closes #20813 --------- Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
parent
1f47248143
commit
a7c8bb1596
10 changed files with 54 additions and 22 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<Vec<ModuleSpecifier>, 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::<Vec<_>>(),
|
||||
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),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
5
tests/specs/cache/globbing/__test__.jsonc
vendored
Normal file
5
tests/specs/cache/globbing/__test__.jsonc
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "cache *.ts",
|
||||
"output": "Download http://localhost:4545/echo.ts\n",
|
||||
"exitCode": 0
|
||||
}
|
1
tests/specs/cache/globbing/excluded.tsx
vendored
Normal file
1
tests/specs/cache/globbing/excluded.tsx
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
import "http://localhost:4545/non-existent.ts";
|
1
tests/specs/cache/globbing/main.ts
vendored
Normal file
1
tests/specs/cache/globbing/main.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
import "http://localhost:4545/echo.ts";
|
24
tests/specs/check/globbing/__test__.jsonc
Normal file
24
tests/specs/check/globbing/__test__.jsonc
Normal file
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
0
tests/specs/check/globbing/excluded.tsx
Normal file
0
tests/specs/check/globbing/excluded.tsx
Normal file
1
tests/specs/check/globbing/main.ts
Normal file
1
tests/specs/check/globbing/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
console.log("globbing_support_done");
|
1
tests/specs/check/globbing/sub_dir/main.ts
Normal file
1
tests/specs/check/globbing/sub_dir/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
const value: number = "";
|
Loading…
Reference in a new issue