Skip to content

Commit

Permalink
fix(cli-separator): negative value on a long text (#553)
Browse files Browse the repository at this point in the history
When `text` is longer than 78 characters, `rest` is negative, which raises
an error at `repeat`, making some commands unusable.
  • Loading branch information
Mesteery authored Sep 3, 2021
1 parent f2f77dd commit 3e8b07d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class CLI {
return;
}
const rest = (length - text.length - 2);
const half = sep.repeat(Math.floor(rest / 2));
const half = sep.repeat(Math.abs(Math.floor(rest / 2)));
if (rest % 2 === 0) {
this.log(`${half} ${chalk.bold(text)} ${half}`);
} else {
Expand Down

0 comments on commit 3e8b07d

Please sign in to comment.