From 0dde3326a6130e6a9d7f42db575f7373fec93897 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Wed, 4 Feb 2026 21:16:54 +0100 Subject: [PATCH] chore(prompts): simplify guide option checks --- .changeset/five-places-shake.md | 5 +++++ packages/prompts/src/box.ts | 2 +- packages/prompts/src/log.ts | 2 +- packages/prompts/src/note.ts | 2 +- packages/prompts/src/password.ts | 2 +- packages/prompts/src/select-key.ts | 2 +- packages/prompts/src/select.ts | 2 +- packages/prompts/src/spinner.ts | 2 +- packages/prompts/src/text.ts | 2 +- 9 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/five-places-shake.md diff --git a/.changeset/five-places-shake.md b/.changeset/five-places-shake.md new file mode 100644 index 00000000..61e9f00d --- /dev/null +++ b/.changeset/five-places-shake.md @@ -0,0 +1,5 @@ +--- +"@clack/prompts": patch +--- + +chore: simplify guide option checks diff --git a/packages/prompts/src/box.ts b/packages/prompts/src/box.ts index af299172..e8f3b326 100644 --- a/packages/prompts/src/box.ts +++ b/packages/prompts/src/box.ts @@ -67,7 +67,7 @@ export const box = (message = '', title = '', opts?: BoxOptions) => { const titlePadding = opts?.titlePadding ?? 1; const contentPadding = opts?.contentPadding ?? 2; const width = opts?.width === undefined || opts.width === 'auto' ? 1 : Math.min(1, opts.width); - const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts?.withGuide ?? settings.withGuide; const linePrefix = !hasGuide ? '' : `${S_BAR} `; const formatBorder = opts?.formatBorder ?? defaultFormatBorder; const symbols = (opts?.rounded ? roundedSymbols : squareSymbols).map(formatBorder); diff --git a/packages/prompts/src/log.ts b/packages/prompts/src/log.ts index 8388abef..7b2627f5 100644 --- a/packages/prompts/src/log.ts +++ b/packages/prompts/src/log.ts @@ -28,7 +28,7 @@ export const log = { }: LogMessageOptions = {} ) => { const parts: string[] = []; - const hasGuide = (withGuide ?? settings.withGuide) !== false; + const hasGuide = withGuide ?? settings.withGuide; const spacingString = !hasGuide ? '' : secondarySymbol; const prefix = !hasGuide ? '' : `${symbol} `; const secondaryPrefix = !hasGuide ? '' : `${secondarySymbol} `; diff --git a/packages/prompts/src/note.ts b/packages/prompts/src/note.ts index 75e3c766..78932967 100644 --- a/packages/prompts/src/note.ts +++ b/packages/prompts/src/note.ts @@ -36,7 +36,7 @@ const wrapWithFormat = (message: string, width: number, format: FormatFn): strin export const note = (message = '', title = '', opts?: NoteOptions) => { const output: Writable = opts?.output ?? process.stdout; - const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts?.withGuide ?? settings.withGuide; const format = opts?.format ?? defaultNoteFormatter; const wrapMsg = wrapWithFormat(message, getColumns(output) - 6, format); const lines = ['', ...wrapMsg.split('\n').map(format), '']; diff --git a/packages/prompts/src/password.ts b/packages/prompts/src/password.ts index 838a3b19..379350f7 100644 --- a/packages/prompts/src/password.ts +++ b/packages/prompts/src/password.ts @@ -16,7 +16,7 @@ export const password = (opts: PasswordOptions) => { input: opts.input, output: opts.output, render() { - const hasGuide = (opts.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts.withGuide ?? settings.withGuide; const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} ${opts.message}\n`; const userInput = this.userInputWithCursor; const masked = this.masked; diff --git a/packages/prompts/src/select-key.ts b/packages/prompts/src/select-key.ts index 8fb9712f..dc5bf24e 100644 --- a/packages/prompts/src/select-key.ts +++ b/packages/prompts/src/select-key.ts @@ -40,7 +40,7 @@ export const selectKey = (opts: SelectKeyOptions) = initialValue: opts.initialValue, caseSensitive: opts.caseSensitive, render() { - const hasGuide = (opts.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts.withGuide ?? settings.withGuide; const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} ${opts.message}\n`; switch (this.state) { diff --git a/packages/prompts/src/select.ts b/packages/prompts/src/select.ts index 751e5200..ecc0011f 100644 --- a/packages/prompts/src/select.ts +++ b/packages/prompts/src/select.ts @@ -113,7 +113,7 @@ export const select = (opts: SelectOptions) => { output: opts.output, initialValue: opts.initialValue, render() { - const hasGuide = (opts.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts.withGuide ?? settings.withGuide; const titlePrefix = `${symbol(this.state)} `; const titlePrefixBar = `${symbolBar(this.state)} `; const messageLines = wrapTextWithPrefix( diff --git a/packages/prompts/src/spinner.ts b/packages/prompts/src/spinner.ts index 5e002074..15869e76 100644 --- a/packages/prompts/src/spinner.ts +++ b/packages/prompts/src/spinner.ts @@ -127,7 +127,7 @@ export const spinner = ({ return min > 0 ? `[${min}m ${secs}s]` : `[${secs}s]`; }; - const hasGuide = (opts.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts.withGuide ?? settings.withGuide; const start = (msg = ''): void => { isSpinnerActive = true; diff --git a/packages/prompts/src/text.ts b/packages/prompts/src/text.ts index 2c3dbc8c..2842d21f 100644 --- a/packages/prompts/src/text.ts +++ b/packages/prompts/src/text.ts @@ -20,7 +20,7 @@ export const text = (opts: TextOptions) => { signal: opts.signal, input: opts.input, render() { - const hasGuide = (opts?.withGuide ?? settings.withGuide) !== false; + const hasGuide = opts?.withGuide ?? settings.withGuide; const titlePrefix = `${hasGuide ? `${color.gray(S_BAR)}\n` : ''}${symbol(this.state)} `; const title = `${titlePrefix}${opts.message}\n`; const placeholder = opts.placeholder