summaryrefslogtreecommitdiff
path: root/cli/module_graph.rs
diff options
context:
space:
mode:
authorLiam Murphy <liampm32@gmail.com>2021-05-10 16:06:13 +1000
committerGitHub <noreply@github.com>2021-05-10 08:06:13 +0200
commit7a9ebd15852eee7b676a671098d63bece679e0f7 (patch)
tree188c5b64a0a30f6c62382aef80b32eec98d91bc1 /cli/module_graph.rs
parent84733d90c7cf9b6768acf78f4204b2293f2d1bc0 (diff)
feat: add deno test --watch (#9160)
This commit implements file watching for deno test. When a file is changed, only the test modules which use it as a dependency are rerun. This is accomplished by reworking the file watching infrastructure to pass the paths which have changed to the resolver, and then constructing a module graph for each test module to check if it contains any changed files.
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r--cli/module_graph.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/module_graph.rs b/cli/module_graph.rs
index 93930c8a5..2300e89d6 100644
--- a/cli/module_graph.rs
+++ b/cli/module_graph.rs
@@ -1248,6 +1248,18 @@ impl Graph {
self.modules.get_mut(s)
}
+ pub fn get_specifier(
+ &self,
+ specifier: &ModuleSpecifier,
+ ) -> Result<&Module, AnyError> {
+ let s = self.resolve_specifier(specifier);
+ match self.get_module(s) {
+ ModuleSlot::Module(m) => Ok(m.as_ref()),
+ ModuleSlot::Err(e) => Err(anyhow!(e.to_string())),
+ _ => Err(GraphError::MissingSpecifier(specifier.clone()).into()),
+ }
+ }
+
/// Consume graph and return list of all module specifiers contained in the
/// graph.
pub fn get_modules(&self) -> Vec<ModuleSpecifier> {