mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
lib: Add a function to filter sources by regular expressions.
This commit is contained in:
parent
624cd8ae9e
commit
cb96ed615e
1 changed files with 6 additions and 0 deletions
|
@ -26,6 +26,12 @@ rec {
|
|||
|
||||
cleanSource = builtins.filterSource cleanSourceFilter;
|
||||
|
||||
# Filter sources by a list of regular expressions.
|
||||
#
|
||||
# E.g. `src = sourceByRegex ./my-subproject [".*\.py$" "^database.sql$"]`
|
||||
sourceByRegex = src: regexes: builtins.filterSource (path: type:
|
||||
let relPath = lib.removePrefix (toString src + "/") (toString path);
|
||||
in lib.any (re: builtins.match re relPath != null) regexes) src;
|
||||
|
||||
# Get all files ending with the specified suffices from the given
|
||||
# directory or its descendants. E.g. `sourceFilesBySuffices ./dir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue