Expose paths::PATH_SEPARATOR

This commit is contained in:
Félix Saparelli 2022-01-15 15:58:11 +13:00
parent 97070c815c
commit 431ef710ee
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
2 changed files with 10 additions and 8 deletions

View File

@ -8,7 +8,7 @@ use futures::{pin_mut, Stream, StreamExt};
use tokio::fs::{metadata, read_dir};
use tracing::{trace, trace_span};
use crate::project::ProjectType;
use crate::{project::ProjectType, paths::PATH_SEPARATOR};
/// An ignore file.
///
@ -171,7 +171,7 @@ pub async fn from_environment() -> (Vec<IgnoreFile>, Vec<Error>) {
for path in env::var("WATCHEXEC_IGNORE_FILES")
.unwrap_or_default()
.split(',')
.split(PATH_SEPARATOR)
{
discover_file(&mut files, &mut errors, None, None, PathBuf::from(path)).await;
}

View File

@ -8,6 +8,13 @@ use std::{
use crate::event::{Event, FileType, Tag};
/// The separator for paths used in environment variables.
#[cfg(unix)]
pub const PATH_SEPARATOR: &str = ":";
/// The separator for paths used in environment variables.
#[cfg(not(unix))]
pub const PATH_SEPARATOR: &str = ";";
/// Returns the longest common prefix of all given paths.
///
/// This is a utility function which is useful for finding the common root of a set of origins.
@ -67,11 +74,6 @@ where
pub fn summarise_events_to_env<'events>(
events: impl IntoIterator<Item = &'events Event>,
) -> HashMap<&'static str, OsString> {
#[cfg(unix)]
const ENV_SEP: &str = ":";
#[cfg(not(unix))]
const ENV_SEP: &str = ";";
let mut all_trunks = Vec::new();
let mut kind_buckets = HashMap::new();
for event in events {
@ -148,7 +150,7 @@ pub fn summarise_events_to_env<'events>(
paths.sort();
paths.into_iter().enumerate().for_each(|(i, path)| {
if i > 0 {
joined.push(ENV_SEP);
joined.push(PATH_SEPARATOR);
}
joined.push(path);
});