Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Directory

A Directory is the physical representation of a grouped list of files. While a Folder is a virtual abstraction, the Directory does load all files located at the path into memory.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create a new instance by providing a folder path.

    Will populate the filePaths property with the result of the listFiles method using the rootPath as a parameter.

    Parameters

    • rootPath: string

      absolute folder where to load files from

    Returns Directory

Properties

filePaths

filePaths: string[] = []

array of files (absolute paths) inside the given rootPath

modules

modules: any[] = []

array of modules, 1:1 mapped to the filePaths compiled from source

rootPath

rootPath: string

the folder where the files are located

Methods

listFiles

  • listFiles(cwd: string): string[]
  • Convenience method for loading files recursively from a folder. Returns an array of file paths as strings. Will be called from the constructor with the pre-filled rootPath.

    Parameters

    • cwd: string

      the absolute path where to search for files from

    Returns string[]

loadModule

  • loadModule(filePath: string): any
  • Read and compile a javascript module directly. Is NOT cached and does NOT use the native 'require' naively. This should work even when mocked.

    Parameters

    • filePath: string

    Returns any

Generated using TypeDoc