diff options
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 121d2b4ed..3ca7b5e32 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -9,7 +9,6 @@ pub mod package_json; pub use self::import_map::resolve_import_map_from_specifier; use self::package_json::PackageJsonDeps; use ::import_map::ImportMap; -use deno_config::glob::PathOrPattern; use deno_core::resolve_url_or_path; use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot; use deno_npm::NpmSystemInfo; @@ -244,7 +243,7 @@ impl BenchOptions { } } -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct FmtOptions { pub check: bool, pub options: FmtOptionsConfig, @@ -252,6 +251,14 @@ pub struct FmtOptions { } impl FmtOptions { + pub fn new_with_base(base: PathBuf) -> Self { + Self { + check: false, + options: FmtOptionsConfig::default(), + files: FilePatterns::new_with_base(base), + } + } + pub fn resolve( maybe_fmt_config: Option<FmtConfig>, maybe_fmt_flags: Option<FmtFlags>, @@ -369,7 +376,7 @@ pub enum LintReporterKind { Compact, } -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct LintOptions { pub rules: LintRulesConfig, pub files: FilePatterns, @@ -377,6 +384,14 @@ pub struct LintOptions { } impl LintOptions { + pub fn new_with_base(base: PathBuf) -> Self { + Self { + rules: Default::default(), + files: FilePatterns::new_with_base(base), + reporter_kind: Default::default(), + } + } + pub fn resolve( maybe_lint_config: Option<LintConfig>, maybe_lint_flags: Option<LintFlags>, @@ -1648,7 +1663,8 @@ fn resolve_files( maybe_file_flags: Option<FileFlags>, initial_cwd: &Path, ) -> Result<FilePatterns, AnyError> { - let mut maybe_files_config = maybe_files_config.unwrap_or_default(); + let mut maybe_files_config = maybe_files_config + .unwrap_or_else(|| FilePatterns::new_with_base(initial_cwd.to_path_buf())); if let Some(file_flags) = maybe_file_flags { if !file_flags.include.is_empty() { maybe_files_config.include = @@ -1665,18 +1681,7 @@ fn resolve_files( )?; } } - Ok(FilePatterns { - include: { - let files = match maybe_files_config.include { - Some(include) => include, - None => PathOrPatternSet::new(vec![PathOrPattern::Path( - initial_cwd.to_path_buf(), - )]), - }; - Some(files) - }, - exclude: maybe_files_config.exclude, - }) + Ok(maybe_files_config) } /// Resolves the no_prompt value based on the cli flags and environment. @@ -1896,6 +1901,7 @@ mod test { let resolved_files = resolve_files( Some(FilePatterns { + base: temp_dir_path.to_path_buf(), include: Some( PathOrPatternSet::from_relative_path_or_patterns( temp_dir_path, |