[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.

[ci] format

authored by

Hyper-Z11 and committed by
bombshell-bot
(Aug 25, 2025, 10:46 AM UTC) 42556736 9999adf0

+13 -11
+8 -6
packages/prompts/src/note.ts
··· 1 + import process from 'node:process'; 1 2 import type { Writable } from 'node:stream'; 2 3 import { stripVTControlCharacters as strip } from 'node:util'; 4 + import { wrapAnsi } from 'fast-wrap-ansi'; 3 5 import color from 'picocolors'; 4 6 import { 5 7 type CommonOptions, ··· 10 12 S_CORNER_TOP_RIGHT, 11 13 S_STEP_SUBMIT, 12 14 } from './common.js'; 13 - import { wrapAnsi } from "fast-wrap-ansi"; 14 - import process from "node:process"; 15 15 16 16 export interface NoteOptions extends CommonOptions { 17 17 format?: (line: string) => string; ··· 19 19 20 20 const defaultNoteFormatter = (line: string): string => color.dim(line); 21 21 22 - const wrapWithFormat = (message: string, width: number, format: NoteOptions["format"]): string => { 23 - const wrapMsg = wrapAnsi(message, width).split("\n"); 22 + const wrapWithFormat = (message: string, width: number, format: NoteOptions['format']): string => { 23 + const wrapMsg = wrapAnsi(message, width).split('\n'); 24 24 const maxWidthNormal = wrapMsg.reduce((sum, ln) => Math.max(strip(ln).length, sum), 0); 25 - const maxWidthFormat = wrapMsg.map(format).reduce((sum, ln) => Math.max(strip(ln).length, sum), 0); 25 + const maxWidthFormat = wrapMsg 26 + .map(format) 27 + .reduce((sum, ln) => Math.max(strip(ln).length, sum), 0); 26 28 const wrapWidth = width - (maxWidthFormat - maxWidthNormal); 27 29 return wrapAnsi(message, wrapWidth); 28 - } 30 + }; 29 31 30 32 export const note = (message = '', title = '', opts?: NoteOptions) => { 31 33 const output: Writable = opts?.output ?? process.stdout;
+5 -5
packages/prompts/test/note.test.ts
··· 64 64 expect(output.buffer).toMatchSnapshot(); 65 65 }); 66 66 67 - test('don\'t overflow', () => { 68 - const input = `${'test string '.repeat(32)}\n`.repeat(4).trim(); 67 + test("don't overflow", () => { 68 + const input = `${'test string '.repeat(32)}\n`.repeat(4).trim(); 69 69 prompts.note(input, 'title', { 70 70 input, 71 71 output: Object.assign(output, { columns: 75 }), ··· 74 74 expect(output.buffer).toMatchSnapshot(); 75 75 }); 76 76 77 - test('don\'t overflow with formatter', () => { 78 - const input = `${'test string '.repeat(32)}\n`.repeat(4).trim(); 77 + test("don't overflow with formatter", () => { 78 + const input = `${'test string '.repeat(32)}\n`.repeat(4).trim(); 79 79 prompts.note(input, 'title', { 80 - format: (line) => colors.red(`* ${colors.cyan(line)} *`), 80 + format: (line) => colors.red(`* ${colors.cyan(line)} *`), 81 81 input, 82 82 output: Object.assign(output, { columns: 75 }), 83 83 });