File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ function main() {
88 `${ colors . red ( "I" ) } ${ colors . yellowBright ( "am" ) } ${ colors . yellow ( "the" ) } ${ colors . green ( "rainbow" ) } ${ colors . blue ( "banner" ) } ` ,
99 ) ;
1010
11+ consola . box ( {
12+ title : "longer title" ,
13+ message : "short msg" ,
14+ } ) ;
15+
1116 consola . box ( {
1217 title : "Box with options" ,
1318 message : `I am a banner with different options` ,
Original file line number Diff line number Diff line change @@ -256,8 +256,10 @@ export function box(text: string, _opts: BoxOpts = {}) {
256256 opts . style . padding % 2 === 0 ? opts . style . padding : opts . style . padding + 1 ;
257257 const height = textLines . length + paddingOffset ;
258258 const width =
259- Math . max ( ...textLines . map ( ( line ) => stripAnsi ( line ) . length ) ) +
260- paddingOffset ;
259+ Math . max (
260+ ...textLines . map ( ( line ) => stripAnsi ( line ) . length ) ,
261+ opts . title ? stripAnsi ( opts . title ) . length : 0 ,
262+ ) + paddingOffset ;
261263 const widthOffset = width + paddingOffset ;
262264
263265 const leftSpace =
You can’t perform that action at this time.
0 commit comments