@rogerpence/rp-utils
    Preparing search index...

    Function deleteFile

    • Deletes a file from the filesystem if it exists.

      Parameters

      • filePath: string

        The path to the file to delete

      Returns Promise<boolean>

      A promise that resolves when the file is deleted or doesn't exist

      This function silently succeeds if the file doesn't exist (no error is thrown). If the file exists but cannot be deleted due to permissions or other errors, the error is logged to the console but the function completes normally.

      Delete a file:

      await deleteFile('path/to/file.txt');
      console.log('File deleted or did not exist');

      Delete a validation errors file:

      const errorFilePath = path.join(
      getAppPath(import.meta.url, "tests\\test-data\\output"),
      "markdown-validation-errors.txt"
      );
      await deleteFile(errorFilePath);