diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-08-01 20:49:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 00:49:09 +0000 |
commit | 1cefa831fd74b14121494045a347024502d74e34 (patch) | |
tree | cc7791cf674e427fe4165262db416e6c537e99a3 /cli/args/config_file.rs | |
parent | 36ae37604a0ddab4349df6eb6fafb8ae39fd20fc (diff) |
feat(unstable): optional `deno_modules` directory (#19977)
Closes #15633
Diffstat (limited to 'cli/args/config_file.rs')
-rw-r--r-- | cli/args/config_file.rs | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs index 66b80b9d4..bbbc60e4d 100644 --- a/cli/args/config_file.rs +++ b/cli/args/config_file.rs @@ -673,6 +673,7 @@ pub struct ConfigFileJson { pub lock: Option<Value>, pub exclude: Option<Value>, pub node_modules_dir: Option<bool>, + pub deno_modules_dir: Option<bool>, } #[derive(Clone, Debug)] @@ -858,6 +859,26 @@ impl ConfigFile { self.json.node_modules_dir } + pub fn deno_modules_dir(&self) -> Option<bool> { + self.json.deno_modules_dir + } + + pub fn deno_modules_dir_path(&self) -> Option<PathBuf> { + if self.json.deno_modules_dir == Some(true) { + Some( + self + .specifier + .to_file_path() + .unwrap() + .parent() + .unwrap() + .join("deno_modules"), + ) + } else { + None + } + } + pub fn to_import_map_value(&self) -> Value { let mut value = serde_json::Map::with_capacity(2); if let Some(imports) = &self.json.imports { @@ -874,13 +895,17 @@ impl ConfigFile { } pub fn to_files_config(&self) -> Result<Option<FilesConfig>, AnyError> { - let exclude: Vec<String> = if let Some(exclude) = self.json.exclude.clone() - { - serde_json::from_value(exclude) - .context("Failed to parse \"exclude\" configuration")? - } else { - Vec::new() - }; + let mut exclude: Vec<String> = + if let Some(exclude) = self.json.exclude.clone() { + serde_json::from_value(exclude) + .context("Failed to parse \"exclude\" configuration")? + } else { + Vec::new() + }; + + if self.deno_modules_dir() == Some(true) { + exclude.push("deno_modules".to_string()); + } let raw_files_config = SerializedFilesConfig { exclude, |