( runtime: Runtime, path: string, content: string, abortSignal?: AbortSignal )
| 83 | * Write string contents to a file atomically |
| 84 | */ |
| 85 | export async function writeFileString( |
| 86 | runtime: Runtime, |
| 87 | path: string, |
| 88 | content: string, |
| 89 | abortSignal?: AbortSignal |
| 90 | ): Promise<void> { |
| 91 | const stream = runtime.writeFile(path, abortSignal); |
| 92 | const writer = stream.getWriter(); |
| 93 | try { |
| 94 | await writer.write(new TextEncoder().encode(content)); |
| 95 | await writer.close(); |
| 96 | } catch (err) { |
| 97 | writer.releaseLock(); |
| 98 | throw err; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Result from reading a plan file with legacy migration support |
no test coverage detected