Skip to main content

condense_tool_output

Function condense_tool_output 

Source
pub fn condense_tool_output(raw: &str, max_lines: usize) -> String
Expand description

Reduce a package manager’s failure output to the part that says what went wrong.

A failing npm ci prints its entire usage screen — around a hundred and twenty lines of flags — and dev-prune used to relay every one of them into the middle of a prune report. The three lines that identified the problem were somewhere in there, and the report they were in became unreadable.

So: if any line looks like a diagnostic, show only those; otherwise show the first few lines, which is where a tool that is not npm usually puts its complaint. The count of what was dropped is always printed, and the line naming a full log file is always kept — the whole point of condensing is that the full text stays reachable.