zibri
    Preparing search index...

    Class FsUtilitiesAbstract

    Encapsulates functionality of the fs package.

    Index

    Constructors

    Properties

    separator: "\\" | "/" = path.sep

    The file system separator.

    Methods

    • Return the last portion of a path. Similar to the Unix basename command. Often used to extract the file name from a fully qualified path.

      Parameters

      • p: Path

        The path to evaluate.

      Returns string

      The last portion of the given path.

    • Creates a file at the given path.

      Parameters

      • p: Path

        The path of the new file to create.

      • data: string | string[]

        The data to write into the file. Can be a raw data string or an array of lines, which are joined by \n.

      • recursive: boolean = true

        Whether or not to recursively create the file.

      Returns Promise<void>

    • Creates a new read stream on the file at the given path.

      Parameters

      • path: Path

        The path to read from.

      • Optionaloptions: ReadStreamOptions

        Additional streaming options.

      Returns ReadStream

      The newly created read stream.

    • Creates a new write stream on the file at the given path.

      Parameters

      • path: Path

        The path to write to.

      • Optionaloptions: WriteStreamOptions

        Additional streaming options.

      Returns WriteStream

      The newly created write stream.

    • Return the directory name of a path. Similar to the Unix dirname command.

      Parameters

      • p: Path

        The path to evaluate.

      Returns string

      The name of the directory as a string.

    • Checks if a file at the given path exists.

      Parameters

      • path: Path

        The path to check.

      Returns Promise<boolean>

      True when a file could be accessed and false otherwise.

    • Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.

      Parameters

      • p: Path

        The path to evaluate.

      Returns string

      The file extension.

    • Gets a path from the provided segments.

      Parameters

      • ...paths: string[]

        The segments to get the path from.

      Returns Path

      The cleaned up path.

      When the path could not be built from the provided segments.

    • Perform an asynchronous glob search for the pattern(s) specified.

      Parameters

      • pattern: string | string[]

        The pattern to search for.

      Returns Promise<Path[]>

      The matching paths.

    • Creates a directory at the given path.

      Parameters

      • path: Path

        The path of the directory to create.

      • recursive: boolean = true

        Whether or not missing directories in the path should be created as well. Defaults to true.

      Returns Promise<void>

    • Gets the root level subdirectories and files of the directory at the provided path.

      Parameters

      • path: Path

        The path of the directory to get the contents of.

      Returns Promise<Dirent<string>[]>

      An array of the directory contents.

    • Reads the file content at the given path. Expects utf-8.

      Parameters

      • path: Path

        The path of the file to read.

      Returns Promise<string>

      The content as a single string.

    • Same as readFile, but returns the content as an array of lines instead.

      Parameters

      • path: Path

        The path of the file to read the lines from.

      Returns Promise<string[]>

      The content as an array of line strings.

    • Solve the relative path from {from} to {to} based on the current working directory. At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.

      Parameters

      • from: Path

        Where the relative path should start.

      • to: Path

        Where the relative path should end/point to.

      Returns Path

      The fully resolved relative path.

    • Renames "from" to "to".

      Parameters

      • from: string

        The old path.

      • to: string

        The new path.

      Returns Promise<void>

    • The right-most parameter is considered {to}. Other parameters are considered an array of {from}. Starting from leftmost {from} parameter, resolves {to} to an absolute path. If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.

      Parameters

      • ...paths: string[]

        The paths that should be resolved.

      Returns Path

      The resolved path.

    • Removes either a file or directory.

      Parameters

      • path: Path

        The path to remove.

      • recursive: boolean = true

        Whether or not subdirectories should be deleted as well. Defaults to true.

      Returns Promise<void>

    • Gives information about the file or directory at the provided path.

      Parameters

      • path: Path

        The path to get info on.

      Returns Promise<Stats>

      Information like file size etc.

    • Updates the file at the given path with the given data. Can either replace, prepend or append.

      Parameters

      • path: Path

        The path of the new file to create.

      • data: string | string[]

        The data to write into the file. Can be a raw data string or an array of lines, which are joined by \n.

      • action: "replace" | "prepend" | "append"

        Whether the data should replace the current content or be pre-/appended.

      Returns Promise<void>

    • Either creates or overrides the file at the given path with the given data.

      Parameters

      • path: Path

        The path of the file to create/override.

      • data: string | string[]

        The data to write into the file. Can be a raw data string or an array of lines, which are joined by \n.

      Returns Promise<void>