Skip to content

Commit 21308d9

Browse files
committed
format
1 parent 778aff8 commit 21308d9

File tree

10 files changed

+49
-30
lines changed

10 files changed

+49
-30
lines changed

packages/prompts/src/autocomplete.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { AutocompletePrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
3+
import { cursor } from 'sisteransi';
44
import {
55
type CommonPromptOptions,
6+
clearPrompt,
67
S_BAR,
78
S_BAR_END,
89
S_CHECKBOX_INACTIVE,
910
S_CHECKBOX_SELECTED,
1011
S_RADIO_ACTIVE,
1112
S_RADIO_INACTIVE,
1213
symbol,
13-
clearPrompt,
1414
} from './common.js';
1515
import { limitOptions } from './limit-options.js';
1616
import type { Option } from './select.js';
@@ -106,7 +106,9 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
106106
const label =
107107
selected.length > 0 ? ` ${color.dim(selected.map(getLabel).join(', '))}` : '';
108108

109-
return clearPrompt(opts) ? cursor.up() :`${headings.join('\n')}\n${color.gray(S_BAR)}${label}`;
109+
return clearPrompt(opts)
110+
? cursor.up()
111+
: `${headings.join('\n')}\n${color.gray(S_BAR)}${label}`;
110112
}
111113

112114
case 'cancel': {
@@ -279,7 +281,9 @@ export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOpti
279281
// Render prompt state
280282
switch (this.state) {
281283
case 'submit': {
282-
return clearPrompt(opts) ? cursor.up() : `${title}${color.gray(S_BAR)} ${color.dim(`${this.selectedValues.length} items selected`)}`;
284+
return clearPrompt(opts)
285+
? cursor.up()
286+
: `${title}${color.gray(S_BAR)} ${color.dim(`${this.selectedValues.length} items selected`)}`;
283287
}
284288
case 'cancel': {
285289
return `${title}${color.gray(S_BAR)} ${color.strikethrough(color.dim(userInput))}`;

packages/prompts/src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ export interface CommonPromptOptions extends CommonOptions {
6565

6666
export const clearPrompt = (opts: CommonPromptOptions) => {
6767
return Boolean(opts.clearPromptOnDone && typeof opts.clearPromptOnDone === 'boolean');
68-
}
68+
};

packages/prompts/src/confirm.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { ConfirmPrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
3+
import { cursor } from 'sisteransi';
44
import {
55
type CommonPromptOptions,
6+
clearPrompt,
67
S_BAR,
78
S_BAR_END,
89
S_RADIO_ACTIVE,
910
S_RADIO_INACTIVE,
1011
symbol,
11-
clearPrompt,
1212
} from './common.js';
1313

1414
export interface ConfirmOptions extends CommonPromptOptions {
@@ -33,7 +33,9 @@ export const confirm = (opts: ConfirmOptions) => {
3333

3434
switch (this.state) {
3535
case 'submit':
36-
return clearPrompt(opts) ? cursor.up() : `${title}${color.gray(S_BAR)} ${color.dim(value)}`;
36+
return clearPrompt(opts)
37+
? cursor.up()
38+
: `${title}${color.gray(S_BAR)} ${color.dim(value)}`;
3739
case 'cancel':
3840
return `${title}${color.gray(S_BAR)} ${color.strikethrough(
3941
color.dim(value)

packages/prompts/src/group-multi-select.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { GroupMultiSelectPrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
3+
import { cursor } from 'sisteransi';
44
import {
55
type CommonPromptOptions,
6+
clearPrompt,
67
S_BAR,
78
S_BAR_END,
89
S_CHECKBOX_ACTIVE,
910
S_CHECKBOX_INACTIVE,
1011
S_CHECKBOX_SELECTED,
1112
symbol,
12-
clearPrompt,
1313
} from './common.js';
1414
import type { Option } from './select.js';
1515

packages/prompts/src/multi-select.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { MultiSelectPrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
3+
import { cursor } from 'sisteransi';
44
import {
55
type CommonPromptOptions,
6+
clearPrompt,
67
S_BAR,
78
S_BAR_END,
89
S_CHECKBOX_ACTIVE,
910
S_CHECKBOX_INACTIVE,
1011
S_CHECKBOX_SELECTED,
1112
symbol,
12-
clearPrompt,
1313
} from './common.js';
1414
import { limitOptions } from './limit-options.js';
1515
import type { Option } from './select.js';
@@ -88,12 +88,14 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
8888

8989
switch (this.state) {
9090
case 'submit': {
91-
return clearPrompt(opts) ? cursor.up() : `${title}${color.gray(S_BAR)} ${
92-
this.options
93-
.filter(({ value: optionValue }) => value.includes(optionValue))
94-
.map((option) => opt(option, 'submitted'))
95-
.join(color.dim(', ')) || color.dim('none')
96-
}`;
91+
return clearPrompt(opts)
92+
? cursor.up()
93+
: `${title}${color.gray(S_BAR)} ${
94+
this.options
95+
.filter(({ value: optionValue }) => value.includes(optionValue))
96+
.map((option) => opt(option, 'submitted'))
97+
.join(color.dim(', ')) || color.dim('none')
98+
}`;
9799
}
98100
case 'cancel': {
99101
const label = this.options

packages/prompts/src/password.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { PasswordPrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
4-
import { type CommonPromptOptions, S_BAR, S_BAR_END, S_PASSWORD_MASK, symbol, clearPrompt } from './common.js';
3+
import { cursor } from 'sisteransi';
4+
import {
5+
type CommonPromptOptions,
6+
clearPrompt,
7+
S_BAR,
8+
S_BAR_END,
9+
S_PASSWORD_MASK,
10+
symbol,
11+
} from './common.js';
512

613
export interface PasswordOptions extends CommonPromptOptions {
714
message: string;

packages/prompts/src/select-key.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SelectKeyPrompt } from '@clack/core';
22
import color from 'picocolors';
33
import { cursor } from 'sisteransi';
4-
import { S_BAR, S_BAR_END, symbol, clearPrompt } from './common.js';
4+
import { clearPrompt, S_BAR, S_BAR_END, symbol } from './common.js';
55
import type { Option, SelectOptions } from './select.js';
66

77
export const selectKey = <Value extends string>(opts: SelectOptions<Value>) => {
@@ -37,10 +37,12 @@ export const selectKey = <Value extends string>(opts: SelectOptions<Value>) => {
3737

3838
switch (this.state) {
3939
case 'submit':
40-
return clearPrompt(opts) ? cursor.up() : `${title}${color.gray(S_BAR)} ${opt(
41-
this.options.find((opt) => opt.value === this.value) ?? opts.options[0],
42-
'selected'
43-
)}`;
40+
return clearPrompt(opts)
41+
? cursor.up()
42+
: `${title}${color.gray(S_BAR)} ${opt(
43+
this.options.find((opt) => opt.value === this.value) ?? opts.options[0],
44+
'selected'
45+
)}`;
4446
case 'cancel':
4547
return `${title}${color.gray(S_BAR)} ${opt(this.options[0], 'cancelled')}\n${color.gray(
4648
S_BAR

packages/prompts/src/select.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import color from 'picocolors';
33
import { cursor } from 'sisteransi';
44
import {
55
type CommonPromptOptions,
6+
clearPrompt,
67
S_BAR,
78
S_BAR_END,
89
S_RADIO_ACTIVE,
910
S_RADIO_INACTIVE,
1011
symbol,
11-
clearPrompt
1212
} from './common.js';
1313
import { limitOptions } from './limit-options.js';
1414

@@ -87,7 +87,9 @@ export const select = <Value>(opts: SelectOptions<Value>) => {
8787

8888
switch (this.state) {
8989
case 'submit':
90-
return clearPrompt(opts) ? cursor.up() : `${title}${color.gray(S_BAR)} ${opt(this.options[this.cursor], 'selected')}`;
90+
return clearPrompt(opts)
91+
? cursor.up()
92+
: `${title}${color.gray(S_BAR)} ${opt(this.options[this.cursor], 'selected')}`;
9193
case 'cancel':
9294
return `${title}${color.gray(S_BAR)} ${opt(
9395
this.options[this.cursor],

packages/prompts/src/text.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TextPrompt } from '@clack/core';
22
import color from 'picocolors';
3-
import { cursor } from "sisteransi";
4-
import { type CommonPromptOptions, S_BAR, S_BAR_END, symbol, clearPrompt } from './common.js';
3+
import { cursor } from 'sisteransi';
4+
import { type CommonPromptOptions, clearPrompt, S_BAR, S_BAR_END, symbol } from './common.js';
55

66
export interface TextOptions extends CommonPromptOptions {
77
message: string;

packages/prompts/test/autocomplete.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('autocomplete', () => {
225225
await result;
226226
expect(output.buffer).toMatchSnapshot();
227227
});
228-
228+
229229
test('clear prompt after done', async () => {
230230
const result = autocomplete({
231231
message: 'foo',

0 commit comments

Comments
 (0)