Function readFileSafeSync

  • Reads a file and returns the file's contents.

    Identical to fs.readFileSync, except that:

    • it uses utf8 encoding by default
    • if operation fails, returns undefined instead of throwing

    Parameters

    • filepath: string

      The path to the file.

    • encoding: BufferEncoding = 'utf8'

      The encoding to use when reading the file.

    Returns string | undefined

    The file's contents or undefined if the file does not exist.

Generated using TypeDoc