Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/project/util/projectUtils"

Index

Type aliases

GlobOptions

GlobOptions: string | string[]

Allows conveniently passing one or many glob patterns to utility functions

Functions

countFiles

  • Count files matching the given predicate in this project If no predicate is supplied, does at least one file match the glob pattern? No guarantees about ordering

    Type parameters

    • T

    Parameters

    • p: ProjectAsync
    • globPatterns: GlobOptions

      positive and negative globs to match

    • Default value test: function = () => true

      return a boolean or promise. Defaults to true

        • (f: File): false | true | Promise<boolean>
        • Parameters

          Returns false | true | Promise<boolean>

    Returns Promise<number>

deleteFiles

  • Delete files matching the glob pattern and extra test (if supplied)

    Type parameters

    • T

    Parameters

    • project: ProjectAsync

      project to act on

    • globPatterns: GlobOptions

      glob patterns for files to delete

    • Default value test: function = () => true

      additional, optional test for files to be deleted

        • (f: File): boolean
        • Parameters

          Returns boolean

    Returns Promise<number>

doWithFiles

  • doWithFiles<P>(project: P, globPatterns: GlobOptions, op: function): Promise<P>
  • Perform the same operation on all the files.

    Type parameters

    Parameters

    • project: P

      project to act on

    • globPatterns: GlobOptions

      glob patterns to match

    • op: function

      operation to perform on files. Can return void or a promise.

        • (f: File): void | Promise<any>
        • Parameters

          Returns void | Promise<any>

    Returns Promise<P>

fileExists

  • Does at least one file matching the given predicate exist in this project? If no predicate is supplied, does at least one file match the glob pattern? No guarantees about ordering

    Type parameters

    • T

    Parameters

    • p: ProjectAsync
    • globPatterns: GlobOptions

      positive and negative globs to match

    • Default value test: function = () => true

      return a boolean or promise. Defaults to true

        • (f: File): false | true | Promise<boolean>
        • Parameters

          Returns false | true | Promise<boolean>

    Returns Promise<boolean>

fileIterator

  • Async generator to iterate over files.

    Parameters

    • project: Project

      to act on

    • globPatterns: GlobOptions

      glob pattern for files to match

    • Default value filter: function = async () => true

      function to determine whether this file should be included. Include all files if this function isn't supplied.

        • (f: File): Promise<boolean>
        • Parameters

          Returns Promise<boolean>

    Returns AsyncIterable<File>

gatherFromFiles

  • Gather values from files

    Type parameters

    • T

    Parameters

    • project: ProjectAsync

      to act on

    • globPatterns: GlobOptions

      glob pattern for files to match

    • gather: function

      function returning a promise (of the value you're gathering) from each file. Undefined returns will be filtered out

        • (f: File): Promise<T> | undefined
        • Parameters

          Returns Promise<T> | undefined

    Returns Promise<T[]>

toPromise

Generated using TypeDoc