summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration_tests.rs21
-rw-r--r--cli/tools/fmt.rs8
-rw-r--r--cli/tools/lint.rs9
3 files changed, 31 insertions, 7 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 47acdc9ee..72746f423 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -537,7 +537,9 @@ mod integration {
.expect("Failed to spawn script")
.wait()
.expect("Failed to wait for child process");
- assert!(status.success());
+ // No target files found
+ assert!(!status.success());
+
// Check without ignore.
let status = util::deno_cmd()
.current_dir(util::root_path())
@@ -551,6 +553,7 @@ mod integration {
.wait()
.expect("Failed to wait for child process");
assert!(!status.success());
+
// Format the source file.
let status = util::deno_cmd()
.current_dir(util::root_path())
@@ -4986,6 +4989,7 @@ console.log("finish");
fn lint_ignore_unexplicit_files() {
let output = util::deno_cmd()
.current_dir(util::root_path())
+ .env("NO_COLOR", "1")
.arg("lint")
.arg("--unstable")
.arg("--ignore=./")
@@ -4994,14 +4998,18 @@ console.log("finish");
.unwrap()
.wait_with_output()
.unwrap();
- assert!(output.status.success());
- assert_eq!(output.stderr, b"Checked 0 file\n");
+ assert!(!output.status.success());
+ assert_eq!(
+ String::from_utf8_lossy(&output.stderr),
+ "error: No target files found.\n"
+ );
}
#[test]
fn fmt_ignore_unexplicit_files() {
let output = util::deno_cmd()
.current_dir(util::root_path())
+ .env("NO_COLOR", "1")
.arg("fmt")
.arg("--check")
.arg("--ignore=./")
@@ -5010,8 +5018,11 @@ console.log("finish");
.unwrap()
.wait_with_output()
.unwrap();
- assert!(output.status.success());
- assert_eq!(output.stderr, b"Checked 0 file\n");
+ assert!(!output.status.success());
+ assert_eq!(
+ String::from_utf8_lossy(&output.stderr),
+ "error: No target files found.\n"
+ );
}
#[test]
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs
index d4002984a..6afcb90af 100644
--- a/cli/tools/fmt.rs
+++ b/cli/tools/fmt.rs
@@ -37,7 +37,13 @@ pub async fn format(
) -> Result<(), AnyError> {
let target_file_resolver = || {
// collect the files that are to be formatted
- collect_files(&args, &ignore, is_supported_ext_fmt)
+ collect_files(&args, &ignore, is_supported_ext_fmt).and_then(|files| {
+ if files.is_empty() {
+ Err(generic_error("No target files found."))
+ } else {
+ Ok(files)
+ }
+ })
};
let operation = |paths: Vec<PathBuf>| {
let config = get_typescript_config();
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs
index 165f32233..2f31c88d6 100644
--- a/cli/tools/lint.rs
+++ b/cli/tools/lint.rs
@@ -47,7 +47,14 @@ pub async fn lint_files(
if args.len() == 1 && args[0].to_string_lossy() == "-" {
return lint_stdin(json);
}
- let target_files = collect_files(&args, &ignore, is_supported_ext)?;
+ let target_files =
+ collect_files(&args, &ignore, is_supported_ext).and_then(|files| {
+ if files.is_empty() {
+ Err(generic_error("No target files found."))
+ } else {
+ Ok(files)
+ }
+ })?;
debug!("Found {} files", target_files.len());
let target_files_len = target_files.len();