Skip to content

Commit

Permalink
Merge pull request #1096 from chdh/chdh/helpFix
Browse files Browse the repository at this point in the history
Remove trailing blanks from wrapped help text
  • Loading branch information
abetomo committed Nov 15, 2019
2 parents 35404b8 + 11abe21 commit f7778ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit f7778ce

Please sign in to comment.