Skip to content

Fix .description(): do not set command description if undefined is provided in the first parameter #1966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
*/
description(str, argsDescription) {
if (str === undefined && argsDescription === undefined) return this._description;
Copy link
Contributor Author

@aweebit aweebit Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative solution not allowing to change only the arguments description:

Suggested change
if (str === undefined && argsDescription === undefined) return this._description;
if (str === undefined) return this._description;

(and leave the next line untouched)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like this alternative solution better, and argsDescription is deprecated. But it would technically be a breaking change. I think simpler just to leave it alone (and one day get rid of argsDescription).

this._description = str;
if (str) {
this._description = str;
}
if (argsDescription) {
this._argsDescription = argsDescription;
}
Expand Down