|
1 | 1 | #!/usr/bin/env -S pnpm tsx |
2 | 2 | import { spawn } from "node:child_process"; |
3 | 3 | import { appendFileSync, readFileSync, writeFileSync } from "node:fs"; |
4 | | -import { readFile, rm, writeFile } from "node:fs/promises"; |
| 4 | +import { readFile, rm } from "node:fs/promises"; |
5 | 5 | import path from "node:path"; |
6 | 6 | import { pathToFileURL } from "node:url"; |
7 | 7 | import { |
@@ -638,28 +638,25 @@ class NpmUpdateSmoke {
|
638 | 638 | onOutput: (text: string) => void = () => undefined, |
639 | 639 | ): Promise<number> { |
640 | 640 | return new Promise((resolve, reject) => { |
| 641 | +writeFileSync(logPath, "", "utf8"); |
641 | 642 | const child = spawn(command, args, { |
642 | 643 | cwd: repoRoot, |
643 | 644 | env: { ...process.env, ...env }, |
644 | 645 | stdio: ["ignore", "pipe", "pipe"], |
645 | 646 | }); |
646 | | -let log = ""; |
647 | 647 | child.stdout.on("data", (chunk: Buffer) => { |
648 | 648 | const text = chunk.toString("utf8"); |
649 | | -log += text; |
| 649 | +appendFileSync(logPath, text, "utf8"); |
650 | 650 | onOutput(text); |
651 | 651 | }); |
652 | 652 | child.stderr.on("data", (chunk: Buffer) => { |
653 | 653 | const text = chunk.toString("utf8"); |
654 | | -log += text; |
| 654 | +appendFileSync(logPath, text, "utf8"); |
655 | 655 | onOutput(text); |
656 | 656 | }); |
657 | 657 | child.on("error", reject); |
658 | 658 | child.on("close", (code) => { |
659 | | -void (async () => { |
660 | | -await writeFile(logPath, log, "utf8"); |
661 | | -resolve(code ?? 1); |
662 | | -})(); |
| 659 | +resolve(code ?? 1); |
663 | 660 | }); |
664 | 661 | }); |
665 | 662 | } |
|