Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ProjectAsync

Asynchronous Project operations, returning promises or node streams.

Hierarchy

Index

Properties

Readonly cache

cache: Record<string, object>

Use to cache arbitrary content associated with this instance. Use for smallish objects that are expensive to compute.

id

Readonly name

name: string

Methods

add

  • add(f: File): Promise<this>

addDirectory

  • addDirectory(path: string): Promise<this>
  • Add an empty directory to the project. Should be preserved through all transformations, although may not be accessible in some implementations.

    Parameters

    • path: string

      path to directory relative to root of project

    Returns Promise<this>

addFile

  • addFile(path: string, content: string): Promise<this>
  • Add the given file to the project. Path can be nested. Content is a literal string.

    Parameters

    • path: string

      path to file relative to root of project

    • content: string

      The content to be placed in the new file

    Returns Promise<this>

deleteDirectory

  • deleteDirectory(path: string): Promise<this>
  • Recursively delete a directory and all its contents. Path can be nested. Errors when deleting the directory do not result in a rejected Promise being returned.

    Parameters

    • path: string

      path to directory relative to root of project

    Returns Promise<this>

deleteFile

  • deleteFile(path: string): Promise<this>
  • Delete the given file from the project. Path can be nested. Errors when deleting the file do not result in a rejected Promise being returned.

    Parameters

    • path: string

      path to file relative to root of project

    Returns Promise<this>

findFile

  • findFile(path: string): Promise<File>
  • Attempt to find a regular file at path. This method will return a rejected Promise if the file does not exist or is not a regular file. You may well want getFile, which returns a Promise of the file or undefined.

    Parameters

    • path: string

      path to file relative to root of project

    Returns Promise<File>

getFile

  • getFile(path: string): Promise<File | undefined>
  • Attempt to find a regular file at path. Never throws an exception, returns undefined if file does not exist or is not a regular file.

    Parameters

    • path: string

      path to file relative to root of project

    Returns Promise<File | undefined>

getFiles

  • getFiles(globPatterns?: string | string[]): Promise<File[]>
  • Get files matching these patterns glob patterns.

    Parameters

    • Optional globPatterns: string | string[]

    Returns Promise<File[]>

hasDirectory

  • hasDirectory(path: string): Promise<boolean>
  • Does a directory exist at this path? It will return false if directory does not exist or if file at path is not a directory.

    Parameters

    • path: string

      path to directory relative to root of project

    Returns Promise<boolean>

hasFile

  • hasFile(path: string): Promise<boolean>
  • Does a regular file exist at this path? It will return false for non-existent files, directories, block devices, FIFOs, sockets, etc.

    Parameters

    • path: string

      path to file relative to root of project

    Returns Promise<boolean>

makeExecutable

  • makeExecutable(path: string): Promise<this>
  • Make a file executable. Other permissions are unchanged.

    Parameters

    • path: string

      path to file relative to root of project

    Returns Promise<this>

moveFile

  • moveFile(oldPath: string, newPath: string): Promise<this>
  • Move the file. Do not error if it's not found.

    Parameters

    • oldPath: string
    • newPath: string

    Returns Promise<this>

streamFiles

  • streamFiles(...globPatterns: string[]): FileStream
  • Return a node stream of the files in the project meeting the given path criteria. Uses default exclusions in the glob path.

    Parameters

    • Rest ...globPatterns: string[]

      glob patterns per micromatch

    Returns FileStream

streamFilesRaw

  • streamFilesRaw(globPatterns: string[], opts: Options): FileStream
  • Stream file with full control over globs. At least one glob must be provided. No default exclusions will be used.

    Parameters

    • globPatterns: string[]

      glob patterns per micromatch

    • opts: Options

      for glob handling

    Returns FileStream

totalFileCount

  • totalFileCount(): Promise<number>
  • The total number of files in this project or directory

    Returns Promise<number>

    totalFileCount

Generated using TypeDoc