query
On this page

sourceByRegex

lib.sourceByRegex

Docs pulled from | This Revision | about 1 hour ago


Filter sources by a list of regular expressions.

Inputs

src

1. Function argument

regexes

2. Function argument

Examples

sourceByRegex usage example

src = sourceByRegex ./my-subproject [".*\.py$" "^database.sql$"]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

sourceByRegex =
    src: regexes:
    let
      isFiltered = src ? _isLibCleanSourceWith;
      origSrc = if isFiltered then src.origSrc else src;
    in
    lib.cleanSourceWith {
      filter = (
        path: type:
        let
          relPath = lib.removePrefix (toString origSrc + "/") (toString path);
        in
        lib.any (re: match re relPath != null) regexes
      );
      inherit src;
    };