wip
This commit is contained in:
parent
cc89f0c75c
commit
afd28d934e
26 changed files with 2103 additions and 427 deletions
11
data-pipeline/utils/write-json-file.ts
Normal file
11
data-pipeline/utils/write-json-file.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import fs from "fs";
|
||||
|
||||
/**
|
||||
* Writes data as formatted JSON to a file path.
|
||||
* Safely catches and re-throws file system errors.
|
||||
*/
|
||||
export function writeJsonFile(filePath: string, data: unknown): void {
|
||||
const tempPath = `${filePath}.tmp`;
|
||||
fs.writeFileSync(tempPath, JSON.stringify(data, null, 2), "utf-8");
|
||||
fs.renameSync(tempPath, filePath);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue