Function updateJsonFileSafeSync

  • Updates a JSON file based on a provided update function. The update function takes the file's parsed source string as a parameter and should return an object. If the file does not exist or cannot be read, the defaultJson will be used instead.

    Parameters

    • filepath: string

      The path to the file to update.

    • update: ((src) => Record<string | number, unknown>)

      The function to update the file. Takes the current source string as a parameter and should return a string.

        • (src): Record<string | number, unknown>
        • Parameters

          • src: Record<string | number, unknown>

          Returns Record<string | number, unknown>

    • defaultJson: string

      The default string to use if the file cannot be read.

    • options: {
          read?: IJFReadOptions;
          write?: IJsonOutputOptions;
      } = {}

    Returns void

Generated using TypeDoc