Skip to content

Commit

Permalink
chore(rosetta): suppress diagnostics after a certain point (#3158)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rix0rrr authored Nov 12, 2021
1 parent 7501547 commit e303365
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/jsii-rosetta/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit e303365

Please sign in to comment.