diff --git a/src/lib.rs b/src/lib.rs index 713a487..ff31618 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,6 +91,10 @@ pub struct Options { /// lint format and which output stream is used. Defaults to cargo and stdout. #[arg(long)] pub script_path_lints: Option, + + /// Do not touch the following files. + #[arg(long)] + pub ignore_file: Vec } #[derive(Debug, Clone)] @@ -116,6 +120,12 @@ impl FromStr for EnvVar { } pub fn minimize(options: Options) -> Result<()> { + for ignore_file in &options.ignore_file { + if !ignore_file.try_exists()? { + warn!("Ignored path {} does not exist", ignore_file.display()); + } + } + let build = build::Build::new(&options)?; let mut minimizer = Minimizer::new_glob_dir(options, build)?; @@ -162,6 +172,7 @@ impl Default for Options { passes: None, script_path: None, script_path_lints: None, + ignore_file: Vec::new(), } } } diff --git a/src/processor/mod.rs b/src/processor/mod.rs index fed84fc..40c1952 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -79,6 +79,18 @@ impl Minimizer { } }) .filter(|entry| entry.path().extension() == Some(OsStr::new("rs"))) + .filter(|entry| { + if options + .ignore_file + .iter() + .any(|ignored| entry.path().starts_with(ignored)) + { + info!("Ignoring file: {}", entry.path().display()); + false + } else { + true + } + }) .map(|entry| SourceFile { path: entry.into_path(), })