/** * Where the file tools put the pre-write copy of a file. * * Lives in utils because smart_edit and smart_write both make backups, and the * fix below was applied to smart_edit only -- so smart_write went on writing * `.bak` into the user's repository long after the defect was understood. * Measured on this checkout: three stray .bak files, including one beside a * test fixture and one beside a hook that is regenerated by a sync script. * * The backup used to be written NEXT TO THE ORIGINAL. That leaves an untracked * `README.md.bak` in `git status`, one `git add -A` from being committed, and * nothing ever deletes it. A safety net that dirties the tree it is protecting * is a poor trade. * * Backups now live under the user's home directory, keyed by a hash of the * absolute path so two files sharing a basename cannot collide, and capped so * they cannot grow without bound. */ /** Default root: outside every working tree, so a backup can never be committed. */ export declare const BACKUP_ROOT: string; /** * The root to write to right now. * * Read per call rather than captured at import, so a test can redirect it after * this module has already been loaded. */ export declare function backupRoot(): string; /** The directory holding one file's backups. Exported so tests can assert on it. */ export declare function backupDirFor(filePath: string): string; /** * Saves content somewhere it cannot do harm. * * Failure is never allowed to fail the operation -- the backup is a * convenience, the write is the job. But the RETURN VALUE is the outcome, not * the request: callers used to report `wasBackedUp` from the caller's own * option, so a full disk or a read-only home directory produced a result * claiming a backup that was never written. That is precisely the moment * somebody relies on it. * * @returns true only if a backup file is actually on disk. */ export declare function writeBackup(filePath: string, content: string, encoding?: BufferEncoding): boolean; //# sourceMappingURL=file-backup.d.ts.map