(destination: string, content: string, mode?: number)
| 386 | } |
| 387 | |
| 388 | async function writeTextFile(destination: string, content: string, mode?: number): Promise<void> { |
| 389 | await mkdir(dirname(destination), { recursive: true }); |
| 390 | const temporary = `${destination}.devspace-patch-${process.pid}-${randomUUID()}`; |
| 391 | try { |
| 392 | await writeFile(temporary, content, mode === undefined ? undefined : { mode }); |
| 393 | await replaceFile(temporary, destination, await fileExists(destination)); |
| 394 | } catch (error) { |
| 395 | await rm(temporary, { force: true }); |
| 396 | throw error; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | function fileLines(content: string): string[] { |
| 401 | if (content.length === 0) return []; |
no test coverage detected