import { ObjectEncodingOptions, Mode, OpenMode, promises as fsp } from 'node:fs'; type Options = | (ObjectEncodingOptions & { mode?: Mode | undefined; flag?: OpenMode | undefined; }) | BufferEncoding | null | undefined; export const writeFile = async (path: string, content: string, options?: Options) => { if (path.endsWith('.pdf') || content.endsWith('\n')) { await fsp.writeFile(path, content, options); return; } await fsp.writeFile(path, `${content}\n`, options); };