method FileHandlerManager.prototype.updateFile
FileHandlerManager.prototype.updateFile(
filePath: string,
key: string,
newValue: string,
customUpdateFn?: (
content: string,
) => string
): Promise<FileUpdateResult>

Update a file using the appropriate handler

Examples

Example 1

const result = await manager.updateFile(
  "./package.json",
  "version",
  "2.0.0"
);

if (result.success) {
  await Deno.writeTextFile("./package.json", result.content!);
} else {
  console.error(result.error);
}

Parameters

filePath: string

Path to the file to update

key: string

Key to update (e.g., "version")

newValue: string

New value to set

optional
customUpdateFn: (
content: string,
) => string

Optional custom update function

Return Type

Result of the update operation

Usage

import { FileHandlerManager } from ".";