import { readFile, writeFile } from 'node:fs/promises'; export type FileEditor = (content: string) => string | Promise; /** Edits a file using a sync or async editor function */ export const editFile = async ( filePath: string, editor: FileEditor, ): Promise => { const content = await readFile(filePath, 'utf-8'); await writeFile(filePath, await editor(content)); };