[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

fix: note title correctly evaluates title length with ansi

authored by

Simeon Cheeseman and committed by
GitHub
(Apr 17, 2023, 5:22 AM UTC) ab51d291 593f93d0

+8 -2
+5
.changeset/odd-avocados-smile.md
··· 1 + --- 2 + '@clack/prompts': patch 3 + --- 4 + 5 + Fixes cases where the note title length was miscalculated due to ansi characters
+3 -2
packages/prompts/src/index.ts
··· 534 534 const strip = (str: string) => str.replace(ansiRegex(), ''); 535 535 export const note = (message = '', title = '') => { 536 536 const lines = `\n${message}\n`.split('\n'); 537 + const titleLen = strip(title).length; 537 538 const len = 538 539 Math.max( 539 540 lines.reduce((sum, ln) => { 540 541 ln = strip(ln); 541 542 return ln.length > sum ? ln.length : sum; 542 543 }, 0), 543 - strip(title).length 544 + titleLen 544 545 ) + 2; 545 546 const msg = lines 546 547 .map( ··· 552 553 .join('\n'); 553 554 process.stdout.write( 554 555 `${color.gray(S_BAR)}\n${color.green(S_STEP_SUBMIT)} ${color.reset(title)} ${color.gray( 555 - S_BAR_H.repeat(Math.max(len - title.length - 1, 1)) + S_CORNER_TOP_RIGHT 556 + S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT 556 557 )}\n${msg}\n${color.gray(S_CONNECT_LEFT + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n` 557 558 ); 558 559 };