Merge pull request #22912 from teh/sourceRegex

lib: Add a function to filter sources by regular expressions.
This commit is contained in:
Domen Kožar 2017-02-19 17:38:35 +01:00 committed by GitHub
commit 50da0b3019

View File

@ -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