From e3033659d1959c2fa63b40bb6d6eaefeaeeee39d Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Fri, 12 Nov 2021 18:50:35 +0100 Subject: [PATCH] chore(rosetta): suppress diagnostics after a certain point (#3158) In a regular build, Rosetta might throw up hundreds or thousands of warnings about failed translations. Past a certain point, there's just no use to so many error messages any more. Limit the output to 50 at a time. *"But Rico, why no flag to show them all?"* Well, either a human is going to actually look at them and fix them, in which case they're not going to do more than a chunk at a time and re-run Rosetta anyway... or nobody is going to look at them and then what's the point of being able to show all? The count is good enough to get a sense for how bad things are. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- packages/jsii-rosetta/lib/util.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/jsii-rosetta/lib/util.ts b/packages/jsii-rosetta/lib/util.ts index 9642757a9d..9ae8f9db6a 100644 --- a/packages/jsii-rosetta/lib/util.ts +++ b/packages/jsii-rosetta/lib/util.ts @@ -12,9 +12,16 @@ export interface File { } export function printDiagnostics(diags: readonly RosettaDiagnostic[], stream: NodeJS.WritableStream) { - for (const diag of diags) { + // Don't print too much, at some point it just clogs up the log + const maxDiags = 50; + + for (const diag of diags.slice(maxDiags)) { stream.write(diag.formattedMessage); } + + if (diags.length > maxDiags) { + stream.write(`(...and ${maxDiags - diags.length} more diagnostics not shown)`); + } } export const StrictBrand = 'jsii.strict';