From d79b216b75ef7968604d15d83f9c94e465659f71 Mon Sep 17 00:00:00 2001 From: Mestery Date: Wed, 28 Jul 2021 15:53:11 +0200 Subject: [PATCH] fix(cli-separator): negative value on a long text 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 {