diff options
author | Zheyu Zhang <zheyuzhang03@gmail.com> | 2022-02-01 00:39:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-31 17:39:39 +0100 |
commit | 5490cfed2000a063ef0baec500ab7d539203067c (patch) | |
tree | d121da8ad8274de65f77fbced5f452ecb1d7881a /cli/tools/fmt.rs | |
parent | 3e566bb457663cec57602e564f73ded817e426a8 (diff) |
feat(cli): add "--no-clear-screen" flag (#13454)
This commit adds "--no-clear-screen" flag which can be used
with "--watch" flag to disable clearing of terminal screen on
each file change.
Diffstat (limited to 'cli/tools/fmt.rs')
-rw-r--r-- | cli/tools/fmt.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 3044f13d5..a0ab3ea56 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -14,7 +14,7 @@ use crate::config_file::ProseWrap; use crate::diff::diff; use crate::file_watcher; use crate::file_watcher::ResolutionResult; -use crate::flags::FmtFlags; +use crate::flags::{Flags, FmtFlags}; use crate::fs_util::specifier_to_file_path; use crate::fs_util::{collect_files, get_extension}; use crate::text_encoding; @@ -39,8 +39,8 @@ use std::sync::{Arc, Mutex}; /// Format JavaScript/TypeScript files. pub async fn format( + flags: Flags, fmt_flags: FmtFlags, - watch: bool, maybe_fmt_config: Option<FmtConfig>, ) -> Result<(), AnyError> { let FmtFlags { @@ -136,8 +136,16 @@ pub async fn format( Ok(()) }; - if watch { - file_watcher::watch_func(resolver, operation, "Fmt").await?; + if flags.watch.is_some() { + file_watcher::watch_func( + resolver, + operation, + file_watcher::PrintConfig { + job_name: "Fmt".to_string(), + clear_screen: !flags.no_clear_screen, + }, + ) + .await?; } else { let files = collect_files(&include_files, &exclude_files, is_supported_ext_fmt) |