(args: ValidatedWriteFileArgs, tempFilePath?: string)
| 566 | } |
| 567 | |
| 568 | function buildWriteFileScript(args: ValidatedWriteFileArgs, tempFilePath?: string): string { |
| 569 | const contentExpression = tempFilePath |
| 570 | ? `Get-Content -LiteralPath ${powerShellString(tempFilePath)} -Raw` |
| 571 | : powerShellString(args.content) |
| 572 | return `${buildPowerShellPreamble()} |
| 573 | $targetPath = ${powerShellString(args.targetPath)} |
| 574 | $parentPath = Split-Path -Parent $targetPath |
| 575 | if ($parentPath) { |
| 576 | New-Item -ItemType Directory -Path $parentPath -Force | Out-Null |
| 577 | } |
| 578 | $content = ${contentExpression} |
| 579 | $utf8NoBom = [System.Text.UTF8Encoding]::new($false) |
| 580 | [System.IO.File]::WriteAllText($targetPath, $content, $utf8NoBom)` |
| 581 | } |
| 582 | |
| 583 | function buildWriteBufferScript(args: ValidatedWriteBufferArgs, tempFilePath?: string): string { |
| 584 | const base64Expression = tempFilePath |
no test coverage detected