diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-06-28 16:45:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 16:45:55 -0400 |
commit | 01adbb1efb116d72dc24843294f335bd63b24b0a (patch) | |
tree | 920346be399301867567b45356b6613ca03bc109 /cli/tools/fmt.rs | |
parent | 5b7bcefa111b1e4fc1e02bb7fb1c8f152e5fd6aa (diff) |
refactor: add `RootConfig` (#14985)
Diffstat (limited to 'cli/tools/fmt.rs')
-rw-r--r-- | cli/tools/fmt.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index b2aa47373..267b21d88 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -7,13 +7,11 @@ //! the future it can be easily extended to provide //! the same functions as ops available in JS runtime. -use crate::args::Flags; -use crate::args::FmtConfig; use crate::args::FmtFlags; use crate::args::FmtOptionsConfig; use crate::args::ProseWrap; +use crate::args::RootConfig; use crate::colors; -use crate::deno_dir::DenoDir; use crate::diff::diff; use crate::file_watcher; use crate::file_watcher::ResolutionResult; @@ -45,11 +43,11 @@ use super::incremental_cache::IncrementalCache; /// Format JavaScript/TypeScript files. pub async fn format( - flags: &Flags, + config: &RootConfig, fmt_flags: FmtFlags, - maybe_fmt_config: Option<FmtConfig>, - deno_dir: &DenoDir, ) -> Result<(), AnyError> { + let maybe_fmt_config = config.to_fmt_config()?; + let deno_dir = config.resolve_deno_dir()?; let FmtFlags { files, ignore, @@ -138,6 +136,7 @@ pub async fn format( } } }; + let deno_dir = &deno_dir; let operation = |(paths, fmt_options): (Vec<PathBuf>, FmtOptionsConfig)| async move { let incremental_cache = Arc::new(IncrementalCache::new( &deno_dir.fmt_incremental_cache_db_file_path(), @@ -154,13 +153,13 @@ pub async fn format( Ok(()) }; - if flags.watch.is_some() { + if config.watch_paths().is_some() { file_watcher::watch_func( resolver, operation, file_watcher::PrintConfig { job_name: "Fmt".to_string(), - clear_screen: !flags.no_clear_screen, + clear_screen: !config.no_clear_screen(), }, ) .await?; |