From 9fa2bbbaabc71f9bcdcb9bf1571ca70e26c3dac4 Mon Sep 17 00:00:00 2001 From: Alicia Lopez Date: Fri, 3 Sep 2021 11:49:28 +0200 Subject: [PATCH] fix(cli-separator): negative value on a long text (#553) When `text` is longer than 78 characters, `rest` is negative, which raises an error at `repeat`, making some commands unusable. --- lib/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 20eceb6..cde9517 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -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 {