Merge pull request #65083 from basvandijk/fix-composability-of-sourceByRegex
lib: allow sourceByRegex to be composed after cleanSourceWith
This commit is contained in:
commit
4914a82186
|
@ -53,9 +53,13 @@ rec {
|
||||||
# Filter sources by a list of regular expressions.
|
# Filter sources by a list of regular expressions.
|
||||||
#
|
#
|
||||||
# E.g. `src = sourceByRegex ./my-subproject [".*\.py$" "^database.sql$"]`
|
# E.g. `src = sourceByRegex ./my-subproject [".*\.py$" "^database.sql$"]`
|
||||||
sourceByRegex = src: regexes: cleanSourceWith {
|
sourceByRegex = src: regexes:
|
||||||
|
let
|
||||||
|
isFiltered = src ? _isLibCleanSourceWith;
|
||||||
|
origSrc = if isFiltered then src.origSrc else src;
|
||||||
|
in lib.cleanSourceWith {
|
||||||
filter = (path: type:
|
filter = (path: type:
|
||||||
let relPath = lib.removePrefix (toString src + "/") (toString path);
|
let relPath = lib.removePrefix (toString origSrc + "/") (toString path);
|
||||||
in lib.any (re: builtins.match re relPath != null) regexes);
|
in lib.any (re: builtins.match re relPath != null) regexes);
|
||||||
inherit src;
|
inherit src;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue