diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-10-25 01:27:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-25 01:27:00 +0200 |
commit | 95854b88ad4a67afb885322c70bb424352bca49e (patch) | |
tree | 300a57951f31508de56788b8f8f92cc596862a3c /cli/main.rs | |
parent | dd952818bc6b888b8fd1cff6a3d1e6b15993bafb (diff) |
refactor(run): use new module graph for run --watch (#8085)
This commit changes how "deno run --watch" is implemented
by migrating to use ModuleGraph2.
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/cli/main.rs b/cli/main.rs index f89d344c0..382e76f23 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -550,22 +550,24 @@ async fn run_with_watch(flags: Flags, script: String) -> Result<(), AnyError> { let main_module = ModuleSpecifier::resolve_url_or_path(&script)?; let program_state = ProgramState::new(flags.clone())?; - let mut module_graph_loader = module_graph::ModuleGraphLoader::new( - program_state.file_fetcher.clone(), - program_state.maybe_import_map.clone(), + let handler = Rc::new(RefCell::new(FetchHandler::new( + &program_state, Permissions::allow_all(), - false, - false, + )?)); + let mut builder = module_graph2::GraphBuilder2::new( + handler, + program_state.maybe_import_map.clone(), + program_state.lockfile.clone(), ); - module_graph_loader.add_to_graph(&main_module, None).await?; - let module_graph = module_graph_loader.get_graph(); + builder.add(&main_module, false).await?; + let module_graph = builder.get_graph(); // Find all local files in graph let mut paths_to_watch: Vec<PathBuf> = module_graph - .values() - .map(|f| Url::parse(&f.url).unwrap()) - .filter(|url| url.scheme() == "file") - .map(|url| url.to_file_path().unwrap()) + .get_modules() + .iter() + .filter(|specifier| specifier.as_url().scheme() == "file") + .map(|specifier| specifier.as_url().to_file_path().unwrap()) .collect(); if let Some(import_map) = program_state.flags.import_map_path.clone() { |