Skip to content

Commit 0ded19c

Browse files
authored
chore(prompts): simplify guide option checks (#459)
1 parent 0e93ccb commit 0ded19c

File tree

9 files changed

+13
-8
lines changed

9 files changed

+13
-8
lines changed

‎.changeset/five-places-shake.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": patch
3+
---
4+
5+
chore: simplify guide option checks

‎packages/prompts/src/box.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const box = (message = '', title = '', opts?: BoxOptions) => {
6767
const titlePadding = opts?.titlePadding ?? 1;
6868
const contentPadding = opts?.contentPadding ?? 2;
6969
const width = opts?.width === undefined || opts.width === 'auto' ? 1 : Math.min(1, opts.width);
70-
const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false;
70+
const hasGuide = opts?.withGuide ?? settings.withGuide;
7171
const linePrefix = !hasGuide ? '' : `${S_BAR} `;
7272
const formatBorder = opts?.formatBorder ?? defaultFormatBorder;
7373
const symbols = (opts?.rounded ? roundedSymbols : squareSymbols).map(formatBorder);

‎packages/prompts/src/log.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const log = {
2828
}: LogMessageOptions = {}
2929
) => {
3030
const parts: string[] = [];
31-
const hasGuide = (withGuide ?? settings.withGuide) !== false;
31+
const hasGuide = withGuide ?? settings.withGuide;
3232
const spacingString = !hasGuide ? '' : secondarySymbol;
3333
const prefix = !hasGuide ? '' : `${symbol} `;
3434
const secondaryPrefix = !hasGuide ? '' : `${secondarySymbol} `;

‎packages/prompts/src/note.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const wrapWithFormat = (message: string, width: number, format: FormatFn): strin
3636

3737
export const note = (message = '', title = '', opts?: NoteOptions) => {
3838
const output: Writable = opts?.output ?? process.stdout;
39-
const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false;
39+
const hasGuide = opts?.withGuide ?? settings.withGuide;
4040
const format = opts?.format ?? defaultNoteFormatter;
4141
const wrapMsg = wrapWithFormat(message, getColumns(output) - 6, format);
4242
const lines = ['', ...wrapMsg.split('\n').map(format), ''];

‎packages/prompts/src/password.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const password = (opts: PasswordOptions) => {
1616
input: opts.input,
1717
output: opts.output,
1818
render() {
19-
const hasGuide = (opts.withGuide ?? settings.withGuide) !== false;
19+
const hasGuide = opts.withGuide ?? settings.withGuide;
2020
const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} ${opts.message}\n`;
2121
const userInput = this.userInputWithCursor;
2222
const masked = this.masked;

‎packages/prompts/src/select-key.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
4040
initialValue: opts.initialValue,
4141
caseSensitive: opts.caseSensitive,
4242
render() {
43-
const hasGuide = (opts.withGuide ?? settings.withGuide) !== false;
43+
const hasGuide = opts.withGuide ?? settings.withGuide;
4444
const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} ${opts.message}\n`;
4545

4646
switch (this.state) {

‎packages/prompts/src/select.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const select = <Value>(opts: SelectOptions<Value>) => {
113113
output: opts.output,
114114
initialValue: opts.initialValue,
115115
render() {
116-
const hasGuide = (opts.withGuide ?? settings.withGuide) !== false;
116+
const hasGuide = opts.withGuide ?? settings.withGuide;
117117
const titlePrefix = `${symbol(this.state)} `;
118118
const titlePrefixBar = `${symbolBar(this.state)} `;
119119
const messageLines = wrapTextWithPrefix(

‎packages/prompts/src/spinner.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const spinner = ({
127127
return min > 0 ? `[${min}m ${secs}s]` : `[${secs}s]`;
128128
};
129129

130-
const hasGuide = (opts.withGuide ?? settings.withGuide) !== false;
130+
const hasGuide = opts.withGuide ?? settings.withGuide;
131131

132132
const start = (msg = ''): void => {
133133
isSpinnerActive = true;

‎packages/prompts/src/text.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const text = (opts: TextOptions) => {
2020
signal: opts.signal,
2121
input: opts.input,
2222
render() {
23-
const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false;
23+
const hasGuide = opts?.withGuide ?? settings.withGuide;
2424
const titlePrefix = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} `;
2525
const title = `${titlePrefix}${opts.message}\n`;
2626
const placeholder = opts.placeholder

0 commit comments

Comments
 (0)