Skip to content

fix: show full option descriptions in --help output#9233

Open
lovasoa wants to merge 1 commit into
npm:latestfrom
lovasoa:fix/help-description-truncation
Open

fix: show full option descriptions in --help output#9233
lovasoa wants to merge 1 commit into
npm:latestfrom
lovasoa:fix/help-description-truncation

Conversation

@lovasoa

@lovasoa lovasoa commented Apr 14, 2026

Copy link
Copy Markdown

Option descriptions in --help output were truncated to the first line. For example, npm version --help showed:

$ npm version --help
  --allow-same-version
    Prevents throwing an error when `npm version` is used to set the new

instead of the complete text:

$ npm version --help
  --allow-same-version
    Prevents throwing an error when `npm version` is used to set the new
    version to the same value as the current version.

This affected all commands, not just version.

Cause: getUsage() in lib/base-cmd.js used .split(n)[0] on each description, discarding everything after the first newline. Since descriptions are multi-line template literals, this cut most of them off mid-sentence.

Fix: Join all lines of the description into a single string instead of taking only the first line.

The help text for command options was truncated to the first line of each
multi-line description. For example, `npm version --help` showed:

  --allow-same-version
    Prevents throwing an error when `npm version` is used to set the new

Instead of the full description. This affected all commands.

The cause was `.split('\n')[0]` in base-cmd.js getUsage(), which discarded
everything after the first newline. Fix by joining all lines into a single
string.
@lovasoa lovasoa requested a review from a team as a code owner April 14, 2026 08:38
@lovasoa lovasoa mentioned this pull request Apr 14, 2026
@owlstronaut

Copy link
Copy Markdown
Contributor

Okay, I think this was actually an intentional design decision. Some of those descriptions are very long and --help is meant to give you a quick summary - i don't think we want full descriptions in there anyway. npm help version would give you the full text if that is what you wanted, i don't think showing everything here is the answer.

@lovasoa

lovasoa commented Apr 14, 2026

Copy link
Copy Markdown
Author

Sentences are cut in the middle without any explanation. Maybe the output should at least let the use know why and how to get the full description ?

@owlstronaut owlstronaut reopened this Jun 9, 2026
@owlstronaut owlstronaut requested a review from a team as a code owner June 9, 2026 18:16
@owlstronaut

Copy link
Copy Markdown
Contributor

@lovasoa in speaking to the engineer that made the change, I found out it was not intentional 😆 . My apologies. If you want to get this up to date I can review/merge. If not I'll get to the change when I can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants