Skip to content
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

Remove trailing blanks from wrapped help text #1096

Merged
merged 1 commit into from Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -1429,7 +1429,7 @@ function wrap(str, width, indent) {
if (line.slice(-1) === '\n') {
line = line.slice(0, line.length - 1);
}
return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line;
return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line.trimRight();
}).join('\n');
}

Expand Down
8 changes: 4 additions & 4 deletions tests/helpwrap.test.js
Expand Up @@ -13,8 +13,8 @@ test('when long option description then wrap and indent', () => {
`Usage: [options]

Options:
-x -extra-long-option-switch kjsahdkajshkahd kajhsd akhds kashd kajhs dkha
dkh aksd ka dkha kdh kasd ka kahs dkh sdkh
-x -extra-long-option-switch kjsahdkajshkahd kajhsd akhds kashd kajhs dkha
dkh aksd ka dkha kdh kasd ka kahs dkh sdkh
askdh aksd kashdk ahsd kahs dkha skdh
-h, --help output usage information
`;
Expand All @@ -34,7 +34,7 @@ test('when long option description and default then wrap and indent', () => {
`Usage: [options]

Options:
-x -extra-long-option <value> kjsahdkajshkahd kajhsd akhds (default: "aaa
-x -extra-long-option <value> kjsahdkajshkahd kajhsd akhds (default: "aaa
bbb ccc ddd eee fff ggg")
-h, --help output usage information
`;
Expand All @@ -59,7 +59,7 @@ Options:
-h, --help output usage information

Commands:
alpha Lorem mollit quis dolor ex do eu quis ad insa
alpha Lorem mollit quis dolor ex do eu quis ad insa
a commodo esse.
`;

Expand Down