From 82291e8b468bee5489c0bb41d01ef95830c0845a Mon Sep 17 00:00:00 2001 From: Caesarovich <38408878+Caesarovich@users.noreply.github.com> Date: Mon, 13 Sep 2021 14:51:23 +0200 Subject: [PATCH] Fix a regression (#61) Co-authored-by: Mariusz Nowak --- index.d.ts | 4 ++-- index.js | 9 ++++----- package.json | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index a99d5db..69ebd42 100644 --- a/index.d.ts +++ b/index.d.ts @@ -153,12 +153,12 @@ declare namespace boxen { @example ``` - console.log(boxen('foo bar foo bar', {title: 'example', textAlignmentTitle: 'center'})); + console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'center'})); // ┌─── example ───┐ // │foo bar foo bar│ // └───────────────┘ - console.log(boxen('foo bar foo bar', {title: 'example', textAlignmentTitle: 'right'})); + console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'right'})); // ┌────── example ┐ // │foo bar foo bar│ // └───────────────┘ diff --git a/index.js b/index.js index 3b98d04..4d97b92 100644 --- a/index.js +++ b/index.js @@ -227,11 +227,10 @@ module.exports = (text, options) => { if (title) { title = ` ${title} `; - } - - // Make the box larger to fit a larger title - if (stringWidth(title) > contentWidth) { - contentWidth = stringWidth(title); + // Make the box larger to fit a larger title + if (stringWidth(title) > contentWidth) { + contentWidth = stringWidth(title); + } } if ((margin.left && margin.right) && contentWidth + BORDERS_WIDTH + margin.left + margin.right > columns) { diff --git a/package.json b/package.json index 46bbd5f..8482e95 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "camelcase": "^6.2.0", "chalk": "^4.1.0", "cli-boxes": "^2.2.1", - "string-width": "^4.2.0", + "string-width": "^4.2.2", "type-fest": "^0.20.2", "widest-line": "^3.1.0", "wrap-ansi": "^7.0.0"