Skip to content

Commit 9fd94e2

Browse files
43081jgithub-actions[bot]
authored andcommitted
[ci] format
1 parent d25f6d0 commit 9fd94e2

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

packages/prompts/src/box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Writable } from 'node:stream';
22
import { getColumns } from '@clack/core';
3+
import stringWidth from 'fast-string-width';
34
import { wrapAnsi } from 'fast-wrap-ansi';
45
import {
56
type CommonOptions,
@@ -14,7 +15,6 @@ import {
1415
S_CORNER_TOP_LEFT,
1516
S_CORNER_TOP_RIGHT,
1617
} from './common.js';
17-
import stringWidth from "fast-string-width";
1818

1919
export type BoxAlignment = 'left' | 'center' | 'right';
2020

packages/prompts/src/note.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import process from 'node:process';
22
import type { Writable } from 'node:stream';
33
import { getColumns } from '@clack/core';
4+
import stringWidth from 'fast-string-width';
45
import { type Options as WrapAnsiOptions, wrapAnsi } from 'fast-wrap-ansi';
56
import color from 'picocolors';
67
import {
@@ -12,7 +13,6 @@ import {
1213
S_CORNER_TOP_RIGHT,
1314
S_STEP_SUBMIT,
1415
} from './common.js';
15-
import stringWidth from "fast-string-width";
1616

1717
type FormatFn = (line: string) => string;
1818
export interface NoteOptions extends CommonOptions {
@@ -28,9 +28,7 @@ const wrapWithFormat = (message: string, width: number, format: FormatFn): strin
2828
};
2929
const wrapMsg = wrapAnsi(message, width, opts).split('\n');
3030
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);
3432
const wrapWidth = width - (maxWidthFormat - maxWidthNormal);
3533
return wrapAnsi(message, wrapWidth, opts);
3634
};

packages/prompts/test/box.test.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,8 @@ describe.each(['true', 'false'])('box (isCI = %s)', (isCI) => {
236236
});
237237

238238
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'), '这是标题', {
244241
input,
245242
output,
246243
width: 'auto',
@@ -250,11 +247,8 @@ describe.each(['true', 'false'])('box (isCI = %s)', (isCI) => {
250247
});
251248

252249
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'), '这是标题', {
258252
input,
259253
output,
260254
width: 0.2,

packages/prompts/test/note.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,21 @@ describe.each(['true', 'false'])('note (isCI = %s)', (isCI) => {
8787
expect(output.buffer).toMatchSnapshot();
8888
});
8989

90-
test("handle wide characters", () => {
91-
const messages = [
92-
'이게 첫 번째 줄이에요',
93-
'これは次の行です',
94-
];
90+
test('handle wide characters', () => {
91+
const messages = ['이게 첫 번째 줄이에요', 'これは次の行です'];
9592
output.columns = 10;
96-
prompts.note(messages.join("\n"), '这是标题', {
93+
prompts.note(messages.join('\n'), '这是标题', {
9794
input,
9895
output,
9996
});
10097

10198
expect(output.buffer).toMatchSnapshot();
10299
});
103100

104-
test("handle wide characters with formatter", () => {
105-
const messages = [
106-
'이게 첫 번째 줄이에요',
107-
'これは次の行です',
108-
];
101+
test('handle wide characters with formatter', () => {
102+
const messages = ['이게 첫 번째 줄이에요', 'これは次の行です'];
109103
output.columns = 10;
110-
prompts.note(messages.join("\n"), '这是标题', {
104+
prompts.note(messages.join('\n'), '这是标题', {
111105
format: (line) => colors.red(`* ${colors.cyan(line)} *`),
112106
input,
113107
output,

0 commit comments

Comments
 (0)