Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Project

Interface representing a project, allowing transparent operations whether it is sourced from a GitHub or other repository, from local disk or in memory. Allows both read and write operations. The three interfaces it extends allow different styles of operation: scripting (deferred), asynchronous (with promises) or synchronous.

Hierarchy

Implemented by

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

Optional provenance

provenance: string

For debugging: how was this project created?

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>

addFileSync

  • addFileSync(path: string, content: string): void
  • Add the given file to the project. Path can be nested. Content is a literal string. This method will throw an error if it is not successful.

    Parameters

    • path: string

      path to file relative to root of project

    • content: string

      The content to be placed in the new file

    Returns void

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>

deleteDirectorySync

  • deleteDirectorySync(path: string): void
  • Recursively deletes a directory and all its contents with the given path. Errors when deleting the directory are caught.

    Parameters

    • path: string

      path to directory relative to root of project

    Returns void

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>

deleteFileSync

  • deleteFileSync(path: string): void
  • Delete the given file from the project. Path can be nested. Errors when deleting the file are caught.

    Parameters

    • path: string

      path to file relative to root of project

    Returns void

directoryExistsSync

  • directoryExistsSync(path: string): boolean

fileExistsSync

  • fileExistsSync(path: string): boolean
  • Does a regular file with the given path exist? It will return false if the file does not exist or is not a regular file.

    Parameters

    • path: string

      path to file relative to root of project

    Returns boolean

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>

findFileSync

  • findFileSync(path: string): File
  • Find a regular file with the given path. Return undefined if file does not exist or is not a regular file.

    Parameters

    • path: string

      path to file relative to root of project

    Returns 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[]>

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>

makeExecutableSync

  • makeExecutableSync(path: string): void

moveFile

  • moveFile(oldPath: string, newPath: string): Promise<this>

streamFiles

  • streamFiles(...globPatterns: string[]): 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>

Generated using TypeDoc