summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/fmt.rs16
-rw-r--r--cli/tools/lint.rs28
-rw-r--r--cli/tools/standalone.rs1
-rw-r--r--cli/tools/test.rs10
4 files changed, 42 insertions, 13 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)
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs
index b103550e2..74c5540fc 100644
--- a/cli/tools/lint.rs
+++ b/cli/tools/lint.rs
@@ -8,9 +8,10 @@
//! the same functions as ops available in JS runtime.
use crate::config_file::LintConfig;
use crate::file_watcher::ResolutionResult;
-use crate::flags::LintFlags;
+use crate::flags::{Flags, LintFlags};
use crate::fmt_errors;
use crate::fs_util::{collect_files, is_supported_ext, specifier_to_file_path};
+use crate::proc_state::ProcState;
use crate::tools::fmt::run_parallelized;
use crate::{colors, file_watcher};
use deno_ast::MediaType;
@@ -48,11 +49,7 @@ fn create_reporter(kind: LintReporterKind) -> Box<dyn LintReporter + Send> {
}
}
-pub async fn lint(
- maybe_lint_config: Option<LintConfig>,
- lint_flags: LintFlags,
- watch: bool,
-) -> Result<(), AnyError> {
+pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
let LintFlags {
maybe_rules_tags,
maybe_rules_include,
@@ -69,6 +66,13 @@ pub async fn lint(
let mut include_files = args.clone();
let mut exclude_files = ignore.clone();
+ let ps = ProcState::build(flags.clone()).await?;
+ let maybe_lint_config = if let Some(config_file) = &ps.maybe_config_file {
+ config_file.to_lint_config()?
+ } else {
+ None
+ };
+
if let Some(lint_config) = maybe_lint_config.as_ref() {
if include_files.is_empty() {
include_files = lint_config
@@ -166,13 +170,21 @@ pub async fn lint(
Ok(())
};
- if watch {
+ if flags.watch.is_some() {
if args.len() == 1 && args[0].to_string_lossy() == "-" {
return Err(generic_error(
"Lint watch on standard input is not supported.",
));
}
- file_watcher::watch_func(resolver, operation, "Lint").await?;
+ file_watcher::watch_func(
+ resolver,
+ operation,
+ file_watcher::PrintConfig {
+ job_name: "Lint".to_string(),
+ clear_screen: !flags.no_clear_screen,
+ },
+ )
+ .await?;
} else {
if args.len() == 1 && args[0].to_string_lossy() == "-" {
let reporter_lock =
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs
index a0960d051..ec957e195 100644
--- a/cli/tools/standalone.rs
+++ b/cli/tools/standalone.rs
@@ -248,5 +248,6 @@ pub fn compile_to_runtime_flags(
v8_flags: flags.v8_flags,
version: false,
watch: None,
+ no_clear_screen: false,
})
}
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 5e2d74ecf..daae61d7f 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -1279,7 +1279,15 @@ pub async fn run_tests_with_watch(
}
};
- file_watcher::watch_func(resolver, operation, "Test").await?;
+ file_watcher::watch_func(
+ resolver,
+ operation,
+ file_watcher::PrintConfig {
+ job_name: "Test".to_string(),
+ clear_screen: !flags.no_clear_screen,
+ },
+ )
+ .await?;
Ok(())
}