Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "project/util/projectUtils"

Index

Type aliases

GlobOptions

GlobOptions: string | string[]

Allows conveniently passing one or many glob patterns to utility functions

Functions

copyFiles

  • copyFiles<P>(from: Project, to: P): Promise<P>

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: (f: File) => boolean | Promise<boolean> = () => true

      return a boolean or promise. Defaults to true

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

          Returns boolean | 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: (f: File) => boolean = () => 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: (f: File) => void | Promise<any>): 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: (f: File) => void | Promise<any>

      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: (f: File) => boolean | Promise<boolean> = () => true

      return a boolean or promise. Defaults to true

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

          Returns boolean | 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: (f: File) => Promise<boolean> = 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: (f: File) => Promise<T> | undefined

      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