Skip to content

Commit 4255673

Browse files
43081jgithub-actions[bot]
authored andcommitted
[ci] format
1 parent 9999adf commit 4255673

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/prompts/src/note.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import process from 'node:process';
12
import type { Writable } from 'node:stream';
23
import { stripVTControlCharacters as strip } from 'node:util';
4+
import { wrapAnsi } from 'fast-wrap-ansi';
35
import color from 'picocolors';
46
import {
57
type CommonOptions,
@@ -10,22 +12,22 @@ import {
1012
S_CORNER_TOP_RIGHT,
1113
S_STEP_SUBMIT,
1214
} from './common.js';
13-
import { wrapAnsi } from "fast-wrap-ansi";
14-
import process from "node:process";
1515

1616
export interface NoteOptions extends CommonOptions {
1717
format?: (line: string) => string;
1818
}
1919

2020
const defaultNoteFormatter = (line: string): string => color.dim(line);
2121

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');
2424
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);
2628
const wrapWidth = width - (maxWidthFormat - maxWidthNormal);
2729
return wrapAnsi(message, wrapWidth);
28-
}
30+
};
2931

3032
export const note = (message = '', title = '', opts?: NoteOptions) => {
3133
const output: Writable = opts?.output ?? process.stdout;

packages/prompts/test/note.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ describe.each(['true', 'false'])('note (isCI = %s)', (isCI) => {
6464
expect(output.buffer).toMatchSnapshot();
6565
});
6666

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();
6969
prompts.note(input, 'title', {
7070
input,
7171
output: Object.assign(output, { columns: 75 }),
@@ -74,10 +74,10 @@ describe.each(['true', 'false'])('note (isCI = %s)', (isCI) => {
7474
expect(output.buffer).toMatchSnapshot();
7575
});
7676

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();
7979
prompts.note(input, 'title', {
80-
format: (line) => colors.red(`* ${colors.cyan(line)} *`),
80+
format: (line) => colors.red(`* ${colors.cyan(line)} *`),
8181
input,
8282
output: Object.assign(output, { columns: 75 }),
8383
});

0 commit comments

Comments
 (0)