Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

564 B
Raw Blame
import { replaceFileAtomic } from "./replace-file.js";
export async function writeTextAtomic(filePath, content, options) {
    const payload = options?.trailingNewline && !content.endsWith("\n") ? `${content}\n` : content;
    const durable = options?.durable ?? true;
    await replaceFileAtomic({
        filePath,
        content: payload,
        mode: options?.mode ?? 0o600,
        dirMode: options?.dirMode ?? (0o777 & ~process.umask()),
        copyFallbackOnPermissionError: true,
        syncTempFile: durable,
        syncParentDir: durable,
    });
}