Skip to content

Commit ba3df8e

Browse files
authored
fix(prompts): honor withGuide for intro/outro/cancel messages (#474)
1 parent 6086b25 commit ba3df8e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.changeset/quiet-experts-itch.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+
Fixes withGuide support in intro, outro, and cancel messages.

packages/prompts/src/messages.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import type { Writable } from 'node:stream';
22
import { styleText } from 'node:util';
3+
import { settings } from '@clack/core';
34
import { type CommonOptions, S_BAR, S_BAR_END, S_BAR_START } from './common.js';
45

56
export const cancel = (message = '', opts?: CommonOptions) => {
67
const output: Writable = opts?.output ?? process.stdout;
7-
output.write(`${styleText('gray', S_BAR_END)} ${styleText('red', message)}\n\n`);
8+
const hasGuide = opts?.withGuide ?? settings.withGuide;
9+
const prefix = hasGuide ? `${styleText('gray', S_BAR_END)} ` : '';
10+
output.write(`${prefix}${styleText('red', message)}\n\n`);
811
};
912

1013
export const intro = (title = '', opts?: CommonOptions) => {
1114
const output: Writable = opts?.output ?? process.stdout;
12-
output.write(`${styleText('gray', S_BAR_START)} ${title}\n`);
15+
const hasGuide = opts?.withGuide ?? settings.withGuide;
16+
const prefix = hasGuide ? `${styleText('gray', S_BAR_START)} ` : '';
17+
output.write(`${prefix}${title}\n`);
1318
};
1419

1520
export const outro = (message = '', opts?: CommonOptions) => {
1621
const output: Writable = opts?.output ?? process.stdout;
17-
output.write(`${styleText('gray', S_BAR)}\n${styleText('gray', S_BAR_END)} ${message}\n\n`);
22+
const hasGuide = opts?.withGuide ?? settings.withGuide;
23+
const prefix = hasGuide ? `${styleText('gray', S_BAR)}\n${styleText('gray', S_BAR_END)} ` : '';
24+
output.write(`${prefix}${message}\n\n`);
1825
};

0 commit comments

Comments
 (0)