Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(theme): theme:check --json writes reports over 64 KB in full (#10384)

Jiayuan Zhang8cd84eefcbb8
diff --git a/scripts/theme-check.mjs b/scripts/theme-check.mjs
index 70023d213e..d8c7d824b3 100644
--- a/scripts/theme-check.mjs
+++ b/scripts/theme-check.mjs
@@ -70,4 +70,6 @@ if (json) {
console.log(`\n${errors === 0 ? "Passed" : "Failed"}: ${errors} error${errors === 1 ? "" : "s"}, ${warnings} warning${warnings === 1 ? "" : "s"}.`);
}
-process.exit(reports.every((report) => report.ok) ? 0 : 1);
+// Not process.exit(): it drops stdout still queued for a pipe, which cuts a
+// --json report off at 64 KB.
+process.exitCode = reports.every((report) => report.ok) ? 0 : 1;
diff --git a/scripts/theme-check.test.mjs b/scripts/theme-check.test.mjs
index 3542dbd1a0..6bc9f8f69c 100644
--- a/scripts/theme-check.test.mjs
+++ b/scripts/theme-check.test.mjs
@@ -73,6 +73,22 @@ test("fails a theme on an option value other than the default", (t) => {
assert.ok(failing.every((c) => c.variant?.option === "screen" && c.variant.value === "amber"));
});
+test("writes a --json report larger than a pipe buffer in full", (t) => {
+ const dir = mkdtempSync(join(tmpdir(), "theme-check-"));
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
+ const choices = Array.from({ length: 8 }, (_, i) => ({ value: `s${i}`, label: `Screen ${i}` }));
+ const screens = theme(dir, "screens", {
+ manifest: { options: [{ id: "screen", type: "select", label: "Screen", default: "s0", choices }] },
+ css: ".theme-light { --radius: 0.25rem; }\n",
+ });
+
+ const result = run(screens, "--json");
+ assert.equal(result.status, 0, result.stderr);
+ assert.ok(result.stdout.length > 65536, `the report is only ${result.stdout.length} bytes`);
+ const [report] = JSON.parse(result.stdout);
+ assert.equal(report.ok, true);
+});
+
test("explains a path that is not a theme", () => {
const result = run(join(tmpdir(), "no-such-theme-folder"));
assert.equal(result.status, 1);