Skip to content

Commit a0f588e

Browse files
chore(hooks): limit phpstan error output to 1000 chars
1 parent fbeabc4 commit a0f588e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.cursor/hooks/run-phpstan-on-stop.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,24 @@ async function main(): Promise<void> {
6060
return;
6161
}
6262

63+
const MAX_ERROR_CHARS = 1000;
64+
6365
const { ok, output } = runCommand(COMMAND.tool, COMMAND.cmd);
6466
const failures = ok ? [] : [{ tool: COMMAND.tool, output }];
6567

68+
const truncatedOutput =
69+
output && output.length > MAX_ERROR_CHARS
70+
? output.slice(0, MAX_ERROR_CHARS) + "\n… (truncated)"
71+
: output || "(no output)";
72+
6673
const result =
6774
failures.length > 0
6875
? {
6976
followup_message: [
7077
`Please fix the errors reported by ${COMMAND.tool}.`,
7178
"Don't do any other investigation.",
7279
"",
73-
`<${COMMAND.tool}-errors>\n${output || "(no output)"}\n</${COMMAND.tool}-errors>`,
80+
`<${COMMAND.tool}-errors>\n${truncatedOutput}\n</${COMMAND.tool}-errors>`,
7481
].join("\n"),
7582
}
7683
: {};

0 commit comments

Comments
 (0)