diff options
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r-- | cli/module_graph.rs | 12 |
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> { |