lib.sources.trace: init
This commit is contained in:
parent
4a025692d1
commit
4cf56e5640
|
@ -12,6 +12,7 @@ let
|
||||||
tryEval
|
tryEval
|
||||||
;
|
;
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
|
boolToString
|
||||||
filter
|
filter
|
||||||
getAttr
|
getAttr
|
||||||
isString
|
isString
|
||||||
|
@ -90,6 +91,29 @@ let
|
||||||
name = if name != null then name else orig.name;
|
name = if name != null then name else orig.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add logging to a source, for troubleshooting the filtering behavior.
|
||||||
|
Type:
|
||||||
|
sources.trace :: sourceLike -> Source
|
||||||
|
*/
|
||||||
|
trace =
|
||||||
|
# Source to debug. The returned source will behave like this source, but also log its filter invocations.
|
||||||
|
src:
|
||||||
|
let
|
||||||
|
attrs = toSourceAttributes src;
|
||||||
|
in
|
||||||
|
fromSourceAttributes (
|
||||||
|
attrs // {
|
||||||
|
filter = path: type:
|
||||||
|
let
|
||||||
|
r = attrs.filter path type;
|
||||||
|
in
|
||||||
|
builtins.trace "${attrs.name}.filter ${path} = ${boolToString r}" r;
|
||||||
|
}
|
||||||
|
) // {
|
||||||
|
satisfiesSubpathInvariant = src ? satisfiesSubpathInvariant && src.satisfiesSubpathInvariant;
|
||||||
|
};
|
||||||
|
|
||||||
# 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$"]`
|
||||||
|
@ -233,5 +257,7 @@ in {
|
||||||
|
|
||||||
sourceByRegex
|
sourceByRegex
|
||||||
sourceFilesBySuffices
|
sourceFilesBySuffices
|
||||||
|
|
||||||
|
trace
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue