(filePath: string, content: string)
| 115 | * changes. |
| 116 | */ |
| 117 | export function atomicWriteFileSync(filePath: string, content: string): void { |
| 118 | if (!isSymbolicLink(filePath)) { |
| 119 | writeThenRename(filePath, content, true); |
| 120 | return; |
| 121 | } |
| 122 | let target = filePath; |
| 123 | try { |
| 124 | target = linkTarget(filePath); |
| 125 | writeThenRename(target, content, false); |
| 126 | } catch (err) { |
| 127 | throw linkWriteError(filePath, target, err); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | function writeThenRename(filePath: string, content: string, createFolder: boolean): void { |
| 132 | const dir = path.dirname(filePath); |
no test coverage detected