diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-10-11 08:26:22 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 08:26:22 +1100 |
commit | a7baf5f2bbb50dc0cb571de141b800b9155faca7 (patch) | |
tree | 4bebaabd1d3ed4595e8a388e0fae559bb5558974 /cli/config_file.rs | |
parent | 5a8a989b7815023f33a1e3183a55cc8999af5d98 (diff) |
refactor: integrate deno_graph into CLI (#12369)
Diffstat (limited to 'cli/config_file.rs')
-rw-r--r-- | cli/config_file.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/config_file.rs b/cli/config_file.rs index dd002ca97..3a71d41a9 100644 --- a/cli/config_file.rs +++ b/cli/config_file.rs @@ -10,6 +10,7 @@ use deno_core::serde::Serializer; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; +use deno_core::ModuleSpecifier; use std::collections::BTreeMap; use std::collections::HashMap; use std::fmt; @@ -401,6 +402,19 @@ impl ConfigFile { } } + /// If the configuration file contains "extra" modules (like TypeScript + /// `"types"`) options, return them as imports to be added to a module graph. + pub fn to_maybe_imports( + &self, + ) -> Option<Vec<(ModuleSpecifier, Vec<String>)>> { + let compiler_options_value = self.json.compiler_options.as_ref()?; + let compiler_options: CompilerOptions = + serde_json::from_value(compiler_options_value.clone()).ok()?; + let referrer = ModuleSpecifier::from_file_path(&self.path).ok()?; + let types = compiler_options.types?; + Some(vec![(referrer, types)]) + } + pub fn to_fmt_config(&self) -> Result<Option<FmtConfig>, AnyError> { if let Some(config) = self.json.fmt.clone() { let fmt_config: FmtConfig = serde_json::from_value(config) |