Skip to content

Commit

Permalink
fix(check): should not panic when all specified files excluded (denol…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jan 13, 2024
1 parent daed588 commit d88c869
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use deno_graph::JsonModule;
use deno_graph::Module;
use deno_graph::Resolution;
use deno_lockfile::Lockfile;
use deno_runtime::colors;
use deno_runtime::deno_fs;
use deno_runtime::deno_node::NodeResolution;
use deno_runtime::deno_node::NodeResolutionMode;
Expand Down Expand Up @@ -227,6 +228,11 @@ impl ModuleLoadPreparer {
let lib = self.options.ts_type_lib_window();

let specifiers = self.collect_specifiers(files)?;

if specifiers.is_empty() {
log::warn!("{} No matching files found.", colors::yellow("Warning"));
}

self
.prepare_module_load(
specifiers,
Expand Down
6 changes: 6 additions & 0 deletions cli/tests/integration/check_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ itest!(check_imported_files_listed_in_exclude_option {
exit_code: 1,
});

itest!(check_with_excluded_file_specified {
args: "check lib/types.d.ts",
cwd: Some("check/excluded_file_specified/"),
output: "check/excluded_file_specified/check.out",
});

#[test]
fn cache_switching_config_then_no_config() {
let context = TestContext::default();
Expand Down
1 change: 1 addition & 0 deletions cli/tests/testdata/check/excluded_file_specified/check.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warning No matching files found.
6 changes: 6 additions & 0 deletions cli/tests/testdata/check/excluded_file_specified/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"types": ["./lib/types.d.ts"]
},
"exclude": ["lib"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// deno-lint-ignore-file
declare var test: number;
4 changes: 4 additions & 0 deletions cli/tools/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ impl TypeChecker {
graph: Arc<ModuleGraph>,
options: CheckOptions,
) -> Result<Diagnostics, AnyError> {
if graph.roots.is_empty() {
return Ok(Default::default());
}

// node built-in specifiers use the @types/node package to determine
// types, so inject that now (the caller should do this after the lockfile
// has been written)
Expand Down

0 comments on commit d88c869

Please sign in to comment.