mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
feat: support negated globs in workspace members
This commit is contained in:
parent
33917424a8
commit
dad3fad402
2 changed files with 25 additions and 9 deletions
|
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Print that no updates are available in `outdated` command by @daimond113
|
- Print that no updates are available in `outdated` command by @daimond113
|
||||||
|
- Support negated globs in `workspace_members` field by @daimond113
|
||||||
|
|
||||||
## [0.5.0-rc.12] - 2024-11-22
|
## [0.5.0-rc.12] - 2024-11-22
|
||||||
### Added
|
### Added
|
||||||
|
|
33
src/lib.rs
33
src/lib.rs
|
@ -16,6 +16,7 @@ use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
use tokio::task::spawn_blocking;
|
||||||
|
|
||||||
/// Downloading packages
|
/// Downloading packages
|
||||||
pub mod download;
|
pub mod download;
|
||||||
|
@ -192,15 +193,29 @@ impl Project {
|
||||||
errors::WorkspaceMembersError::ManifestDeser(dir.to_path_buf(), Box::new(e))
|
errors::WorkspaceMembersError::ManifestDeser(dir.to_path_buf(), Box::new(e))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let members = manifest
|
let mut members = HashSet::new();
|
||||||
.workspace_members
|
|
||||||
.into_iter()
|
for glob in &manifest.workspace_members {
|
||||||
.map(|glob| dir.join(glob))
|
let is_removal = glob.starts_with('!');
|
||||||
.map(|path| glob::glob(&path.as_os_str().to_string_lossy()))
|
let glob = if is_removal { &glob[1..] } else { glob };
|
||||||
.collect::<Result<Vec<_>, _>>()?
|
|
||||||
.into_iter()
|
let path = dir.join(glob);
|
||||||
.flat_map(|paths| paths.into_iter())
|
let paths = spawn_blocking(move || {
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
glob::glob(&path.as_os_str().to_string_lossy())?
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.map_err(errors::WorkspaceMembersError::Globbing)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()?;
|
||||||
|
|
||||||
|
if is_removal {
|
||||||
|
for path in paths {
|
||||||
|
members.remove(&path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
members.extend(paths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(stream! {
|
Ok(stream! {
|
||||||
for path in members {
|
for path in members {
|
||||||
|
|
Loading…
Reference in a new issue