diff --git a/cli/src/config/init.rs b/cli/src/config/init.rs index 9a29cb6..4eec8fc 100644 --- a/cli/src/config/init.rs +++ b/cli/src/config/init.rs @@ -3,25 +3,27 @@ use std::convert::Infallible; use clap::ArgMatches; use miette::Result; use tracing::error; -use watchexec::{config::InitConfig, handler::SyncFnHandler, error::RuntimeError}; +use watchexec::{config::InitConfig, error::RuntimeError, handler::SyncFnHandler}; pub fn init(_args: &ArgMatches<'static>) -> Result { let mut config = InitConfig::default(); - config.on_error(SyncFnHandler::from(|data| -> std::result::Result<(), Infallible> { - if let RuntimeError::IoError(_) = data { - // these are often spurious, so condemn them to -v only - error!("{}", data); - return Ok(()); - } + config.on_error(SyncFnHandler::from( + |data| -> std::result::Result<(), Infallible> { + if let RuntimeError::IoError(_) = data { + // these are often spurious, so condemn them to -v only + error!("{}", data); + return Ok(()); + } - if cfg!(debug_assertions) { - eprintln!("[[{:?}]]", data); - } else { - eprintln!("[[{}]]", data); - } + if cfg!(debug_assertions) { + eprintln!("[[{:?}]]", data); + } else { + eprintln!("[[{}]]", data); + } - Ok(()) - })); + Ok(()) + }, + )); Ok(config) } diff --git a/cli/src/filterer/common.rs b/cli/src/filterer/common.rs index 039a304..a94ebb2 100644 --- a/cli/src/filterer/common.rs +++ b/cli/src/filterer/common.rs @@ -9,7 +9,7 @@ use dunce::canonicalize; use miette::{IntoDiagnostic, Result}; use tracing::{debug, warn}; use watchexec::{ - ignore_files::{self, IgnoreFile}, + ignore::{self, files::IgnoreFile}, paths::common_prefix, project::{self, ProjectType}, }; @@ -42,7 +42,7 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result>(); debug!(?vcs_types, "resolved vcs types"); - let (mut ignores, _errors) = ignore_files::from_origin(origin).await; + let (mut ignores, _errors) = ignore::files::from_origin(origin).await; // TODO: handle errors debug!(?ignores, "discovered ignore files from project origin"); @@ -71,7 +71,7 @@ pub async fn ignores(args: &ArgMatches<'static>, origin: &Path) -> Result) -> Result> { diff --git a/lib/src/filter/globset.rs b/lib/src/filter/globset.rs index 3c61498..83794c2 100644 --- a/lib/src/filter/globset.rs +++ b/lib/src/filter/globset.rs @@ -10,7 +10,7 @@ use tracing::{debug, trace, trace_span}; use crate::error::RuntimeError; use crate::event::{Event, FileType}; use crate::filter::Filterer; -use crate::ignore_files::IgnoreFile; +use crate::ignore::files::IgnoreFile; /// A path-only filterer based on globsets. /// diff --git a/lib/src/filter/tagged.rs b/lib/src/filter/tagged.rs index e5e9a54..b279436 100644 --- a/lib/src/filter/tagged.rs +++ b/lib/src/filter/tagged.rs @@ -16,7 +16,7 @@ use crate::error::RuntimeError; use crate::event::{Event, FileType, ProcessEnd, Tag}; use crate::filter::tagged::error::TaggedFiltererError; use crate::filter::Filterer; -use crate::ignore_files::IgnoreFile; +use crate::ignore::files::IgnoreFile; use crate::signal::process::SubSignal; use crate::signal::source::MainSignal; diff --git a/lib/src/filter/tagged/files.rs b/lib/src/filter/tagged/files.rs index d990599..14fdd1c 100644 --- a/lib/src/filter/tagged/files.rs +++ b/lib/src/filter/tagged/files.rs @@ -9,7 +9,7 @@ use std::{ use tokio::fs::read_to_string; -use crate::ignore_files::{discover_file, IgnoreFile}; +use crate::ignore::files::{discover_file, IgnoreFile}; use super::{error::TaggedFiltererError, Filter}; diff --git a/lib/src/ignore.rs b/lib/src/ignore.rs new file mode 100644 index 0000000..9e853c9 --- /dev/null +++ b/lib/src/ignore.rs @@ -0,0 +1,3 @@ +//! Ignore files: find them, parse them, interpret them. + +pub mod files; diff --git a/lib/src/ignore_files.rs b/lib/src/ignore/files.rs similarity index 99% rename from lib/src/ignore_files.rs rename to lib/src/ignore/files.rs index 38cbbaf..93a0c4c 100644 --- a/lib/src/ignore_files.rs +++ b/lib/src/ignore/files.rs @@ -282,7 +282,7 @@ pub(crate) async fn discover_file( Ok(None) => { trace!("found nothing"); false - }, + } Ok(Some(path)) => { trace!(?path, "found a file"); files.push(IgnoreFile { diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 77b1fbb..a8d6e73 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -104,7 +104,7 @@ pub mod error; pub mod event; pub mod filter; pub mod fs; -pub mod ignore_files; +pub mod ignore; pub mod paths; pub mod project; pub mod signal; diff --git a/lib/tests/helpers.rs b/lib/tests/helpers.rs index bfcb41b..2aa92ae 100644 --- a/lib/tests/helpers.rs +++ b/lib/tests/helpers.rs @@ -15,7 +15,7 @@ use watchexec::{ tagged::{files::FilterFile, Filter, Matcher, Op, Pattern, TaggedFilterer}, Filterer, }, - ignore_files::IgnoreFile, + ignore::files::IgnoreFile, project::ProjectType, signal::source::MainSignal, };