mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:00:42 +00:00
feat(secrets): replace migrate flow with audit/configure/apply
This commit is contained in:
committed by
Peter Steinberger
parent
8944b75e16
commit
f413e314b9
@@ -25,3 +25,18 @@ export function writeJsonFileSecure(pathname: string, value: unknown): void {
|
||||
fs.writeFileSync(pathname, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
||||
fs.chmodSync(pathname, 0o600);
|
||||
}
|
||||
|
||||
export function readTextFileIfExists(pathname: string): string | null {
|
||||
if (!fs.existsSync(pathname)) {
|
||||
return null;
|
||||
}
|
||||
return fs.readFileSync(pathname, "utf8");
|
||||
}
|
||||
|
||||
export function writeTextFileAtomic(pathname: string, value: string, mode = 0o600): void {
|
||||
ensureDirForFile(pathname);
|
||||
const tempPath = `${pathname}.tmp-${process.pid}-${Date.now()}`;
|
||||
fs.writeFileSync(tempPath, value, "utf8");
|
||||
fs.chmodSync(tempPath, mode);
|
||||
fs.renameSync(tempPath, pathname);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user