diff options
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index e857a2184..47b4ac752 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -1,8 +1,8 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +use crate::args::CliOptions; use crate::args::DenoSubcommand; use crate::args::Flags; -use crate::args::RootConfig; use crate::args::TypeCheckMode; use crate::cache; use crate::compat; @@ -68,7 +68,7 @@ pub struct Inner { pub dir: deno_dir::DenoDir, pub coverage_dir: Option<String>, pub file_fetcher: FileFetcher, - pub config: Arc<RootConfig>, + pub options: Arc<CliOptions>, graph_data: Arc<RwLock<GraphData>>, pub lockfile: Option<Arc<Mutex<Lockfile>>>, pub maybe_import_map: Option<Arc<ImportMap>>, @@ -91,13 +91,13 @@ impl Deref for ProcState { impl ProcState { pub async fn build(flags: Flags) -> Result<Self, AnyError> { - Self::from_root_config(Arc::new(RootConfig::from_flags(flags)?)).await + Self::from_options(Arc::new(CliOptions::from_flags(flags)?)).await } - pub async fn from_root_config( - root_config: Arc<RootConfig>, + pub async fn from_options( + options: Arc<CliOptions>, ) -> Result<Self, AnyError> { - Self::build_with_sender(root_config, None).await + Self::build_with_sender(options, None).await } pub async fn build_for_file_watcher( @@ -105,18 +105,18 @@ impl ProcState { files_to_watch_sender: tokio::sync::mpsc::UnboundedSender<Vec<PathBuf>>, ) -> Result<Self, AnyError> { // resolve the config each time - let root_config = Arc::new(RootConfig::from_flags(flags)?); + let cli_options = Arc::new(CliOptions::from_flags(flags)?); let ps = - Self::build_with_sender(root_config, Some(files_to_watch_sender.clone())) + Self::build_with_sender(cli_options, Some(files_to_watch_sender.clone())) .await?; // Add the extra files listed in the watch flag - if let Some(watch_paths) = ps.config.watch_paths() { + if let Some(watch_paths) = ps.options.watch_paths() { files_to_watch_sender.send(watch_paths.clone()).unwrap(); } if let Ok(Some(import_map_path)) = ps - .config + .options .resolve_import_map_path() .map(|ms| ms.and_then(|ref s| s.to_file_path().ok())) { @@ -127,33 +127,33 @@ impl ProcState { } async fn build_with_sender( - root_config: Arc<RootConfig>, + cli_options: Arc<CliOptions>, maybe_sender: Option<tokio::sync::mpsc::UnboundedSender<Vec<PathBuf>>>, ) -> Result<Self, AnyError> { let blob_store = BlobStore::default(); let broadcast_channel = InMemoryBroadcastChannel::default(); let shared_array_buffer_store = SharedArrayBufferStore::default(); let compiled_wasm_module_store = CompiledWasmModuleStore::default(); - let dir = root_config.resolve_deno_dir()?; + let dir = cli_options.resolve_deno_dir()?; let deps_cache_location = dir.root.join("deps"); let http_cache = http_cache::HttpCache::new(&deps_cache_location); - let root_cert_store = root_config.resolve_root_cert_store()?; - let cache_usage = root_config.cache_setting(); + let root_cert_store = cli_options.resolve_root_cert_store()?; + let cache_usage = cli_options.cache_setting(); let file_fetcher = FileFetcher::new( http_cache, cache_usage, - !root_config.no_remote(), + !cli_options.no_remote(), Some(root_cert_store.clone()), blob_store.clone(), - root_config + cli_options .unsafely_ignore_certificate_errors() .map(ToOwned::to_owned), )?; - let lockfile = root_config + let lockfile = cli_options .resolve_lock_file()? .map(|f| Arc::new(Mutex::new(f))); - let maybe_import_map_specifier = root_config.resolve_import_map_path()?; + let maybe_import_map_specifier = cli_options.resolve_import_map_path()?; let maybe_import_map = if let Some(import_map_specifier) = maybe_import_map_specifier { @@ -172,9 +172,9 @@ impl ProcState { }; let maybe_inspector_server = - root_config.resolve_inspector_server().map(Arc::new); + cli_options.resolve_inspector_server().map(Arc::new); - let coverage_dir = root_config + let coverage_dir = cli_options .coverage_dir() .map(ToOwned::to_owned) .or_else(|| env::var("DENO_UNSTABLE_COVERAGE_DIR").ok()); @@ -186,12 +186,12 @@ impl ProcState { ); let maybe_import_map_resolver = maybe_import_map.clone().map(ImportMapResolver::new); - let maybe_jsx_resolver = root_config + let maybe_jsx_resolver = cli_options .to_maybe_jsx_import_source_module() .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); let maybe_resolver: Option< Arc<dyn deno_graph::source::Resolver + Send + Sync>, - > = if root_config.compat() { + > = if cli_options.compat() { Some(Arc::new(node_resolver)) } else if let Some(jsx_resolver) = maybe_jsx_resolver { // the JSX resolver offloads to the import map if present, otherwise uses @@ -212,7 +212,7 @@ impl ProcState { Ok(ProcState(Arc::new(Inner { dir, coverage_dir, - config: root_config, + options: cli_options, file_fetcher, graph_data: Default::default(), lockfile, @@ -276,7 +276,7 @@ impl ProcState { // TODO(bartlomieju): this is very make-shift, is there an existing API // that we could include it like with "maybe_imports"? - let roots = if self.config.compat() { + let roots = if self.options.compat() { let mut r = vec![(compat::GLOBAL_URL.clone(), ModuleKind::Esm)]; r.extend(roots); r @@ -285,12 +285,12 @@ impl ProcState { }; if !reload_on_watch { let graph_data = self.graph_data.read(); - if self.config.type_check_mode() == TypeCheckMode::None + if self.options.type_check_mode() == TypeCheckMode::None || graph_data.is_type_checked(&roots, &lib) { if let Some(result) = graph_data.check( &roots, - self.config.type_check_mode() != TypeCheckMode::None, + self.options.type_check_mode() != TypeCheckMode::None, false, ) { return result; @@ -304,7 +304,7 @@ impl ProcState { dynamic_permissions.clone(), ); let maybe_locker = as_maybe_locker(self.lockfile.clone()); - let maybe_imports = self.config.to_maybe_imports()?; + let maybe_imports = self.options.to_maybe_imports()?; struct ProcStateLoader<'a> { inner: &'a mut cache::FetchCacher, @@ -399,17 +399,17 @@ impl ProcState { { let mut graph_data = self.graph_data.write(); graph_data.add_graph(&graph, reload_on_watch); - let check_js = self.config.check_js(); + let check_js = self.options.check_js(); graph_data .check( &roots, - self.config.type_check_mode() != TypeCheckMode::None, + self.options.type_check_mode() != TypeCheckMode::None, check_js, ) .unwrap()?; } - let config_type = if self.config.type_check_mode() == TypeCheckMode::None { + let config_type = if self.options.type_check_mode() == TypeCheckMode::None { TsConfigType::Emit } else { TsConfigType::Check { @@ -419,30 +419,30 @@ impl ProcState { }; let ts_config_result = - self.config.resolve_ts_config_for_emit(config_type)?; + self.options.resolve_ts_config_for_emit(config_type)?; if let Some(ignored_options) = ts_config_result.maybe_ignored_options { log::warn!("{}", ignored_options); } - if self.config.type_check_mode() == TypeCheckMode::None { + if self.options.type_check_mode() == TypeCheckMode::None { let options = emit::EmitOptions { ts_config: ts_config_result.ts_config, - reload: self.config.reload_flag(), + reload: self.options.reload_flag(), reload_exclusions, }; let emit_result = emit::emit(&graph, &self.dir.gen_cache, options)?; log::debug!("{}", emit_result.stats); } else { - let maybe_config_specifier = self.config.maybe_config_file_specifier(); + let maybe_config_specifier = self.options.maybe_config_file_specifier(); let options = emit::CheckOptions { - type_check_mode: self.config.type_check_mode(), - debug: self.config.log_level() == Some(log::Level::Debug), + type_check_mode: self.options.type_check_mode(), + debug: self.options.log_level() == Some(log::Level::Debug), emit_with_diagnostics: false, maybe_config_specifier, ts_config: ts_config_result.ts_config, log_checks: true, - reload: self.config.reload_flag(), + reload: self.options.reload_flag(), reload_exclusions, }; let emit_result = emit::check_and_maybe_emit( @@ -457,7 +457,7 @@ impl ProcState { log::debug!("{}", emit_result.stats); } - if self.config.type_check_mode() != TypeCheckMode::None { + if self.options.type_check_mode() != TypeCheckMode::None { let mut graph_data = self.graph_data.write(); graph_data.set_type_checked(&roots, lib); } @@ -502,7 +502,7 @@ impl ProcState { // and `Deno.core.evalContext` API. Ideally we should always have a referrer filled // but sadly that's not the case due to missing APIs in V8. let referrer = if referrer.is_empty() - && matches!(self.config.sub_command(), DenoSubcommand::Repl(_)) + && matches!(self.options.sub_command(), DenoSubcommand::Repl(_)) { deno_core::resolve_url_or_path("./$deno$repl.ts").unwrap() } else { |