From 95854b88ad4a67afb885322c70bb424352bca49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 25 Oct 2020 01:27:00 +0200 Subject: refactor(run): use new module graph for run --watch (#8085) This commit changes how "deno run --watch" is implemented by migrating to use ModuleGraph2. --- cli/module_graph2.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'cli/module_graph2.rs') diff --git a/cli/module_graph2.rs b/cli/module_graph2.rs index ceb507b01..05bd40783 100644 --- a/cli/module_graph2.rs +++ b/cli/module_graph2.rs @@ -694,11 +694,6 @@ impl Graph2 { Ok((s, stats, maybe_ignored_options)) } - fn contains_module(&self, specifier: &ModuleSpecifier) -> bool { - let s = self.resolve_specifier(specifier); - self.modules.contains_key(s) - } - /// Type check the module graph, corresponding to the options provided. pub fn check( self, @@ -831,6 +826,11 @@ impl Graph2 { Ok((response.stats, response.diagnostics, maybe_ignored_options)) } + fn contains_module(&self, specifier: &ModuleSpecifier) -> bool { + let s = self.resolve_specifier(specifier); + self.modules.contains_key(s) + } + /// Update the handler with any modules that are marked as _dirty_ and update /// any build info if present. fn flush(&mut self) -> Result<(), AnyError> { @@ -949,6 +949,12 @@ impl Graph2 { self.modules.get(s) } + /// Consume graph and return list of all module specifiers + /// contained in the graph. + pub fn get_modules(&self) -> Vec { + self.modules.keys().map(|s| s.to_owned()).collect() + } + /// Get the source for a given module specifier. If the module is not part /// of the graph, the result will be `None`. pub fn get_source(&self, specifier: &ModuleSpecifier) -> Option { -- cgit v1.2.3