diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-06-29 20:41:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-29 20:41:48 -0400 |
commit | e46584a75a5a94cede193945dfd59eed8417aea0 (patch) | |
tree | ed32a276974ccb4e238b3b78c7261df2dff23bc1 /cli/args/mod.rs | |
parent | d5ef14eca65c78f4463a6082b392c3a8b097f7a1 (diff) |
fix(vendor): ignore import map in output directory instead of erroring (#14998)
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 17bbf0603..5844b0fa7 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -44,6 +44,14 @@ use crate::file_fetcher::CacheSetting; use crate::lockfile::Lockfile; use crate::version; +/// Overrides for the options below that when set will +/// use these values over the values derived from the +/// CLI flags or config file. +#[derive(Default)] +struct CliOptionOverrides { + import_map_specifier: Option<Option<ModuleSpecifier>>, +} + /// Holds the common options used by many sub commands /// and provides some helper function for creating common objects. pub struct CliOptions { @@ -51,6 +59,7 @@ pub struct CliOptions { // application need not concern itself with, so keep these private flags: Flags, maybe_config_file: Option<ConfigFile>, + overrides: CliOptionOverrides, } impl CliOptions { @@ -72,6 +81,7 @@ impl CliOptions { Ok(Self { maybe_config_file, flags, + overrides: Default::default(), }) } @@ -113,13 +123,21 @@ impl CliOptions { /// Based on an optional command line import map path and an optional /// configuration file, return a resolved module specifier to an import map. - pub fn resolve_import_map_path( + pub fn resolve_import_map_specifier( &self, ) -> Result<Option<ModuleSpecifier>, AnyError> { - resolve_import_map_specifier( - self.flags.import_map_path.as_deref(), - self.maybe_config_file.as_ref(), - ) + match self.overrides.import_map_specifier.clone() { + Some(path) => Ok(path), + None => resolve_import_map_specifier( + self.flags.import_map_path.as_deref(), + self.maybe_config_file.as_ref(), + ), + } + } + + /// Overrides the import map specifier to use. + pub fn set_import_map_specifier(&mut self, path: Option<ModuleSpecifier>) { + self.overrides.import_map_specifier = Some(path); } pub fn resolve_root_cert_store(&self) -> Result<RootCertStore, AnyError> { |