fix(vendor): ignore import map in output directory instead of erroring (#14998)

This commit is contained in:
David Sherret 2022-06-29 20:41:48 -04:00 committed by GitHub
parent d5ef14eca6
commit e46584a75a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 135 additions and 70 deletions

View file

@ -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> {