[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
(Sep 8, 2025, 7:47 PM UTC) 9fd94e2d d25f6d03

+13 -27
+1 -1
packages/prompts/src/box.ts
··· 1 1 import type { Writable } from 'node:stream'; 2 2 import { getColumns } from '@clack/core'; 3 + import stringWidth from 'fast-string-width'; 3 4 import { wrapAnsi } from 'fast-wrap-ansi'; 4 5 import { 5 6 type CommonOptions, ··· 14 15 S_CORNER_TOP_LEFT, 15 16 S_CORNER_TOP_RIGHT, 16 17 } from './common.js'; 17 - import stringWidth from "fast-string-width"; 18 18 19 19 export type BoxAlignment = 'left' | 'center' | 'right'; 20 20
+2 -4
packages/prompts/src/note.ts
··· 1 1 import process from 'node:process'; 2 2 import type { Writable } from 'node:stream'; 3 3 import { getColumns } from '@clack/core'; 4 + import stringWidth from 'fast-string-width'; 4 5 import { type Options as WrapAnsiOptions, wrapAnsi } from 'fast-wrap-ansi'; 5 6 import color from 'picocolors'; 6 7 import { ··· 12 13 S_CORNER_TOP_RIGHT, 13 14 S_STEP_SUBMIT, 14 15 } from './common.js'; 15 - import stringWidth from "fast-string-width"; 16 16 17 17 type FormatFn = (line: string) => string; 18 18 export interface NoteOptions extends CommonOptions { ··· 28 28 }; 29 29 const wrapMsg = wrapAnsi(message, width, opts).split('\n'); 30 30 const maxWidthNormal = wrapMsg.reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0); 31 - const maxWidthFormat = wrapMsg 32 - .map(format) 33 - .reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0); 31 + const maxWidthFormat = wrapMsg.map(format).reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0); 34 32 const wrapWidth = width - (maxWidthFormat - maxWidthNormal); 35 33 return wrapAnsi(message, wrapWidth, opts); 36 34 };
+4 -10
packages/prompts/test/box.test.ts
··· 236 236 }); 237 237 238 238 test('renders wide characters with auto width', () => { 239 - const messages = [ 240 - '이게 첫 번째 줄이에요', 241 - 'これは次の行です', 242 - ]; 243 - prompts.box(messages.join("\n"), '这是标题', { 239 + const messages = ['이게 첫 번째 줄이에요', 'これは次の行です']; 240 + prompts.box(messages.join('\n'), '这是标题', { 244 241 input, 245 242 output, 246 243 width: 'auto', ··· 250 247 }); 251 248 252 249 test('renders wide characters with specified width', () => { 253 - const messages = [ 254 - '이게 첫 번째 줄이에요', 255 - 'これは次の行です', 256 - ]; 257 - prompts.box(messages.join("\n"), '这是标题', { 250 + const messages = ['이게 첫 번째 줄이에요', 'これは次の行です']; 251 + prompts.box(messages.join('\n'), '这是标题', { 258 252 input, 259 253 output, 260 254 width: 0.2,
+6 -12
packages/prompts/test/note.test.ts
··· 87 87 expect(output.buffer).toMatchSnapshot(); 88 88 }); 89 89 90 - test("handle wide characters", () => { 91 - const messages = [ 92 - '이게 첫 번째 줄이에요', 93 - 'これは次の行です', 94 - ]; 90 + test('handle wide characters', () => { 91 + const messages = ['이게 첫 번째 줄이에요', 'これは次の行です']; 95 92 output.columns = 10; 96 - prompts.note(messages.join("\n"), '这是标题', { 93 + prompts.note(messages.join('\n'), '这是标题', { 97 94 input, 98 95 output, 99 96 }); ··· 101 98 expect(output.buffer).toMatchSnapshot(); 102 99 }); 103 100 104 - test("handle wide characters with formatter", () => { 105 - const messages = [ 106 - '이게 첫 번째 줄이에요', 107 - 'これは次の行です', 108 - ]; 101 + test('handle wide characters with formatter', () => { 102 + const messages = ['이게 첫 번째 줄이에요', 'これは次の行です']; 109 103 output.columns = 10; 110 - prompts.note(messages.join("\n"), '这是标题', { 104 + prompts.note(messages.join('\n'), '这是标题', { 111 105 format: (line) => colors.red(`* ${colors.cyan(line)} *`), 112 106 input, 113 107 output,