|
11 | 11 | // recreates the artifact list and verifies that it has no changes compared to the committed state.
|
12 | 12 |
|
13 | 13 | import { execSync, spawn } from "node:child_process";
|
14 |
| -import fs from "node:fs"; |
| 14 | +import * as fs from "node:fs/promises"; |
| 15 | +import * as readline from "node:readline/promises"; |
15 | 16 | import { parseArgs } from "node:util";
|
16 | 17 | import { artifactListFile } from "#dev/paths";
|
17 | 18 |
|
@@ -50,23 +51,21 @@ const exitCode = new Promise((resolve, reject) => {
|
50 | 51 | child.once("close", code => resolve(code));
|
51 | 52 | });
|
52 | 53 |
|
53 |
| -fs.unlinkSync(artifactListFile); |
| 54 | +await fs.unlink(artifactListFile); |
54 | 55 |
|
55 |
| -for await (const chunk of child.stdout.setEncoding("utf8")) { |
56 |
| - const lines = /** @type {string} */ (chunk) |
57 |
| - .trim() |
58 |
| - .split(/\s/); |
59 |
| - for (const line of lines) { |
60 |
| - /** @type {YarnPackOutputLine} */ |
61 |
| - const json = JSON.parse(line); |
62 |
| - if ("location" in json) { |
63 |
| - // Workaround for false positive reports |
64 |
| - // See https://github.com/yarnpkg/berry/issues/6766 |
65 |
| - if (json.location.startsWith("_build")) { |
66 |
| - continue; |
67 |
| - } |
68 |
| - fs.appendFileSync(artifactListFile, json.location + "\n", "utf8"); |
| 56 | +for await (const line of readline.createInterface({ |
| 57 | + input: child.stdout.setEncoding("utf8"), |
| 58 | + crlfDelay: Number.POSITIVE_INFINITY, |
| 59 | +})) { |
| 60 | + /** @type {YarnPackOutputLine} */ |
| 61 | + const json = JSON.parse(line); |
| 62 | + if ("location" in json) { |
| 63 | + // Workaround for false positive reports |
| 64 | + // See https://github.com/yarnpkg/berry/issues/6766 |
| 65 | + if (json.location.startsWith("_build")) { |
| 66 | + continue; |
69 | 67 | }
|
| 68 | + await fs.appendFile(artifactListFile, json.location + "\n", "utf8"); |
70 | 69 | }
|
71 | 70 | }
|
72 | 71 |
|
|
0 commit comments