diff options
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index e4c0d8556..1e0c72b1c 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -42,6 +42,7 @@ use crate::emit::TsConfigWithIgnoredOptions; use crate::emit::TsTypeLib; use crate::file_fetcher::get_root_cert_store; use crate::file_fetcher::CacheSetting; +use crate::fs_util; use crate::lockfile::Lockfile; use crate::version; @@ -146,6 +147,24 @@ impl CliOptions { self.overrides.import_map_specifier = Some(path); } + /// Resolves the path to use for a local node_modules folder. + pub fn resolve_local_node_modules_folder( + &self, + ) -> Result<Option<PathBuf>, AnyError> { + let path = if !self.flags.node_modules_dir { + return Ok(None); + } else if let Some(config_path) = self + .maybe_config_file + .as_ref() + .and_then(|c| c.specifier.to_file_path().ok()) + { + config_path.parent().unwrap().join("node_modules") + } else { + std::env::current_dir()?.join("node_modules") + }; + Ok(Some(fs_util::canonicalize_path_maybe_not_exists(&path)?)) + } + pub fn resolve_root_cert_store(&self) -> Result<RootCertStore, AnyError> { get_root_cert_store( None, |