diff options
author | Yusuke Tanaka <tanaka.yusuke@stadium.co.jp> | 2021-02-19 21:18:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 07:18:16 -0500 |
commit | 91881b7cd362eed7bf28e09ad2ca0d40a36f1d9b (patch) | |
tree | 0ebd43c4958980485ad90565f06a69f4e732a6d4 /cli/tools | |
parent | 555595e6d02d1fc1adb535df074d258389fab509 (diff) |
fix: lint and fmt error if no target files are found (#9527)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/fmt.rs | 8 | ||||
-rw-r--r-- | cli/tools/lint.rs | 9 |
2 files changed, 15 insertions, 2 deletions
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(); |