Class FileUtils

Constructors

Properties

fileNameFromPath: (filePath: string) => string = fileNameFromPath

Extracts the file name from a given file path, be it relative or absolute

Type declaration

    • (filePath: string): string
    • Parameters

      • filePath: string

        The file path to extract the name from

      Returns string

      The file name

getDirectories: (dirPath: string) => string[] = getDirectories

Get all directories in a directory, does not include nested/subdirectories

Type declaration

    • (dirPath: string): string[]
    • Parameters

      • dirPath: string

        The target directory to search for directories in

      Returns string[]

      An array of directory paths found in the target directory

getFiles: (
    dirPath: string,
    extensions?: string | string[],
    omitTsExtensionForJs?: boolean,
) => string[] = getFiles

Recursively get all files in a directory, including subdirectories

Type declaration

    • (
          dirPath: string,
          extensions?: string | string[],
          omitTsExtensionForJs?: boolean,
      ): string[]
    • Parameters

      • dirPath: string

        The target directory to search for files in

      • extensions: string | string[] = javascriptExtensions

        The file extensions to include when filtering files

      • omitTsExtensionForJs: boolean = false

        Whether to include Typescript files when Javascript files are included

      Returns string[]

      An array of file paths found in the target directory

javascriptExtensions: string[] = javascriptExtensions

List of file extensions for Javascript source files

projectRoot: string = projectRoot

The path for this project's root directory, including the trailing slash and fallbacks for some OS's and containers

relativeProjectPath: (filePath: string) => string = relativeProjectPath

Get the relative path of a file from the project root

Type declaration

    • (filePath: string): string
    • Parameters

      • filePath: string

        The file path to get the relative path for

      Returns string

      The relative path of the file from the project root