mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 14:11:34 +02:00
Move ignore_files one level deeper
in preparation for new ignore functionality
This commit is contained in:
parent
1c99546071
commit
6a541e5f27
@ -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<InitConfig> {
|
||||
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)
|
||||
}
|
||||
|
@ -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<Vec<Ig
|
||||
.collect::<Vec<_>>();
|
||||
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<Vec<Ig
|
||||
debug!(?ignores, "filtered ignores to only those for project vcs");
|
||||
}
|
||||
|
||||
let (mut global_ignores, _errors) = ignore_files::from_environment().await;
|
||||
let (mut global_ignores, _errors) = ignore::files::from_environment().await;
|
||||
// TODO: handle errors
|
||||
debug!(?global_ignores, "discovered ignore files from environment");
|
||||
|
||||
|
@ -9,7 +9,7 @@ use watchexec::{
|
||||
files::{self, FilterFile},
|
||||
Filter, Matcher, Op, Pattern, TaggedFilterer,
|
||||
},
|
||||
ignore_files::IgnoreFile,
|
||||
ignore::files::IgnoreFile,
|
||||
};
|
||||
|
||||
pub async fn tagged(args: &ArgMatches<'static>) -> Result<Arc<TaggedFilterer>> {
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
3
lib/src/ignore.rs
Normal file
3
lib/src/ignore.rs
Normal file
@ -0,0 +1,3 @@
|
||||
//! Ignore files: find them, parse them, interpret them.
|
||||
|
||||
pub mod files;
|
@ -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 {
|
@ -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;
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user