From 3e8b07decef270b127b7e2584051b950c686114d Mon Sep 17 00:00:00 2001 From: Mestery 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 20eceb60..cde95177 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 {