summaryrefslogtreecommitdiff
path: root/cli/module_graph2.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-10-25 01:27:00 +0200
committerGitHub <noreply@github.com>2020-10-25 01:27:00 +0200
commit95854b88ad4a67afb885322c70bb424352bca49e (patch)
tree300a57951f31508de56788b8f8f92cc596862a3c /cli/module_graph2.rs
parentdd952818bc6b888b8fd1cff6a3d1e6b15993bafb (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/module_graph2.rs')
-rw-r--r--cli/module_graph2.rs16
1 files changed, 11 insertions, 5 deletions
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<ModuleSpecifier> {
+ 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<String> {