Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-places-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clack/prompts": patch
---

chore: simplify guide option checks
2 changes: 1 addition & 1 deletion packages/prompts/src/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} `;
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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), ''];
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/select-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const select = <Value>(opts: SelectOptions<Value>) => {
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(
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading