From e46584a75a5a94cede193945dfd59eed8417aea0 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 29 Jun 2022 20:41:48 -0400 Subject: fix(vendor): ignore import map in output directory instead of erroring (#14998) --- cli/args/mod.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'cli/args/mod.rs') 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>, +} + /// 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, + 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, 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) { + self.overrides.import_map_specifier = Some(path); } pub fn resolve_root_cert_store(&self) -> Result { -- cgit v1.2.3