summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/coverage/mod.rs3
-rw-r--r--cli/tools/doc.rs4
-rw-r--r--cli/tools/fmt.rs2
-rw-r--r--cli/tools/lint.rs1
-rw-r--r--cli/tools/standalone.rs29
-rw-r--r--cli/tools/test.rs34
6 files changed, 37 insertions, 36 deletions
diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs
index 6177295a6..2a6467783 100644
--- a/cli/tools/coverage/mod.rs
+++ b/cli/tools/coverage/mod.rs
@@ -23,6 +23,7 @@ use std::fs::File;
use std::io::BufWriter;
use std::io::Write;
use std::path::PathBuf;
+use std::sync::Arc;
use text_lines::TextLines;
use uuid::Uuid;
@@ -559,7 +560,7 @@ pub async fn cover_files(
flags: Flags,
coverage_flags: CoverageFlags,
) -> Result<(), AnyError> {
- let ps = ProcState::build(flags).await?;
+ let ps = ProcState::build(Arc::new(flags)).await?;
let script_coverages =
collect_coverages(coverage_flags.files, coverage_flags.ignore)?;
diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs
index 6e17c9fca..38f8c2918 100644
--- a/cli/tools/doc.rs
+++ b/cli/tools/doc.rs
@@ -96,7 +96,7 @@ pub async fn print_docs(
flags: Flags,
doc_flags: DocFlags,
) -> Result<(), AnyError> {
- let ps = ProcState::build(flags.clone()).await?;
+ let ps = ProcState::build(Arc::new(flags)).await?;
let source_file = doc_flags
.source_file
.unwrap_or_else(|| "--builtin".to_string());
@@ -122,7 +122,7 @@ pub async fn print_docs(
doc_parser.parse_source(
&source_file_specifier,
MediaType::Dts,
- Arc::new(get_types(flags.unstable)),
+ Arc::new(get_types(ps.flags.unstable)),
)
} else {
let module_specifier = resolve_url_or_path(&source_file)?;
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs
index a0ab3ea56..45cf69b86 100644
--- a/cli/tools/fmt.rs
+++ b/cli/tools/fmt.rs
@@ -39,7 +39,7 @@ use std::sync::{Arc, Mutex};
/// Format JavaScript/TypeScript files.
pub async fn format(
- flags: Flags,
+ flags: &Flags,
fmt_flags: FmtFlags,
maybe_fmt_config: Option<FmtConfig>,
) -> Result<(), AnyError> {
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs
index 74c5540fc..1dfda8adc 100644
--- a/cli/tools/lint.rs
+++ b/cli/tools/lint.rs
@@ -50,6 +50,7 @@ fn create_reporter(kind: LintReporterKind) -> Box<dyn LintReporter + Send> {
}
pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> {
+ let flags = Arc::new(flags);
let LintFlags {
maybe_rules_tags,
maybe_rules_include,
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs
index ec957e195..84a1f00fb 100644
--- a/cli/tools/standalone.rs
+++ b/cli/tools/standalone.rs
@@ -99,7 +99,7 @@ pub fn create_standalone_binary(
unstable: flags.unstable,
seed: flags.seed,
location: flags.location.clone(),
- permissions: flags.clone().into(),
+ permissions: flags.permissions_options(),
v8_flags: flags.v8_flags.clone(),
unsafely_ignore_certificate_errors: flags
.unsafely_ignore_certificate_errors
@@ -200,7 +200,7 @@ pub async fn write_standalone_binary(
/// applicable at runtime so are set to their defaults like `false`.
/// - Other flags are inherited.
pub fn compile_to_runtime_flags(
- flags: Flags,
+ flags: &Flags,
baked_args: Vec<String>,
) -> Result<Flags, AnyError> {
// IMPORTANT: Don't abbreviate any of this to `..flags` or
@@ -212,40 +212,41 @@ pub fn compile_to_runtime_flags(
script: "placeholder".to_string(),
}),
allow_all: flags.allow_all,
- allow_env: flags.allow_env,
+ allow_env: flags.allow_env.clone(),
allow_hrtime: flags.allow_hrtime,
- allow_net: flags.allow_net,
- allow_ffi: flags.allow_ffi,
- allow_read: flags.allow_read,
- allow_run: flags.allow_run,
- allow_write: flags.allow_write,
- ca_stores: flags.ca_stores,
- ca_file: flags.ca_file,
+ allow_net: flags.allow_net.clone(),
+ allow_ffi: flags.allow_ffi.clone(),
+ allow_read: flags.allow_read.clone(),
+ allow_run: flags.allow_run.clone(),
+ allow_write: flags.allow_write.clone(),
+ ca_stores: flags.ca_stores.clone(),
+ ca_file: flags.ca_file.clone(),
cache_blocklist: vec![],
cache_path: None,
cached_only: false,
config_path: None,
- coverage_dir: flags.coverage_dir,
+ coverage_dir: flags.coverage_dir.clone(),
enable_testing_features: false,
ignore: vec![],
import_map_path: None,
inspect_brk: None,
inspect: None,
- location: flags.location,
+ location: flags.location.clone(),
lock_write: false,
lock: None,
log_level: flags.log_level,
check: CheckFlag::All,
compat: flags.compat,
unsafely_ignore_certificate_errors: flags
- .unsafely_ignore_certificate_errors,
+ .unsafely_ignore_certificate_errors
+ .clone(),
no_remote: false,
prompt: flags.prompt,
reload: false,
repl: false,
seed: flags.seed,
unstable: flags.unstable,
- v8_flags: flags.v8_flags,
+ v8_flags: flags.v8_flags.clone(),
version: false,
watch: None,
no_clear_screen: false,
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 2cc1ac808..5d99677f2 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -702,7 +702,7 @@ async fn fetch_inline_files(
/// Type check a collection of module and document specifiers.
async fn check_specifiers(
- ps: ProcState,
+ ps: &ProcState,
permissions: Permissions,
specifiers: Vec<(ModuleSpecifier, TestMode)>,
lib: emit::TypeLib,
@@ -972,7 +972,7 @@ fn collect_specifiers_with_test_mode(
/// cannot be run, and therefore need to be marked as `TestMode::Documentation`
/// as well.
async fn fetch_specifiers_with_test_mode(
- ps: ProcState,
+ ps: &ProcState,
include: Vec<String>,
ignore: Vec<PathBuf>,
include_inline: bool,
@@ -999,10 +999,10 @@ pub async fn run_tests(
flags: Flags,
test_flags: TestFlags,
) -> Result<(), AnyError> {
- let ps = ProcState::build(flags.clone()).await?;
- let permissions = Permissions::from_options(&flags.clone().into());
+ let ps = ProcState::build(Arc::new(flags)).await?;
+ let permissions = Permissions::from_options(&ps.flags.permissions_options());
let specifiers_with_mode = fetch_specifiers_with_test_mode(
- ps.clone(),
+ &ps,
test_flags.include.unwrap_or_else(|| vec![".".to_string()]),
test_flags.ignore.clone(),
test_flags.doc,
@@ -1013,30 +1013,26 @@ pub async fn run_tests(
return Err(generic_error("No test modules found"));
}
- let lib = if flags.unstable {
+ let lib = if ps.flags.unstable {
emit::TypeLib::UnstableDenoWindow
} else {
emit::TypeLib::DenoWindow
};
- check_specifiers(
- ps.clone(),
- permissions.clone(),
- specifiers_with_mode.clone(),
- lib,
- )
- .await?;
+ check_specifiers(&ps, permissions.clone(), specifiers_with_mode.clone(), lib)
+ .await?;
if test_flags.no_run {
return Ok(());
}
+ let compat = ps.flags.compat;
test_specifiers(
ps,
permissions,
specifiers_with_mode,
TestSpecifierOptions {
- compat_mode: flags.compat,
+ compat_mode: compat,
concurrent_jobs: test_flags.concurrent_jobs,
fail_fast: test_flags.fail_fast,
filter: test_flags.filter,
@@ -1052,8 +1048,9 @@ pub async fn run_tests_with_watch(
flags: Flags,
test_flags: TestFlags,
) -> Result<(), AnyError> {
+ let flags = Arc::new(flags);
let ps = ProcState::build(flags.clone()).await?;
- let permissions = Permissions::from_options(&flags.clone().into());
+ let permissions = Permissions::from_options(&flags.permissions_options());
let lib = if flags.unstable {
emit::TypeLib::UnstableDenoWindow
@@ -1233,6 +1230,7 @@ pub async fn run_tests_with_watch(
};
let operation = |modules_to_reload: Vec<(ModuleSpecifier, ModuleKind)>| {
+ let flags = flags.clone();
let filter = test_flags.filter.clone();
let include = include.clone();
let ignore = ignore.clone();
@@ -1242,7 +1240,7 @@ pub async fn run_tests_with_watch(
async move {
let specifiers_with_mode = fetch_specifiers_with_test_mode(
- ps.clone(),
+ &ps,
include.clone(),
ignore.clone(),
test_flags.doc,
@@ -1256,7 +1254,7 @@ pub async fn run_tests_with_watch(
.collect::<Vec<(ModuleSpecifier, TestMode)>>();
check_specifiers(
- ps.clone(),
+ &ps,
permissions.clone(),
specifiers_with_mode.clone(),
lib,
@@ -1268,7 +1266,7 @@ pub async fn run_tests_with_watch(
}
test_specifiers(
- ps.clone(),
+ ps,
permissions.clone(),
specifiers_with_mode,
TestSpecifierOptions {