|
1 | 1 | import type { Writable } from 'node:stream'; |
2 | 2 | import { styleText } from 'node:util'; |
| 3 | +import { settings } from '@clack/core'; |
3 | 4 | import { type CommonOptions, S_BAR, S_BAR_END, S_BAR_START } from './common.js'; |
4 | 5 |
|
5 | 6 | export const cancel = (message = '', opts?: CommonOptions) => { |
6 | 7 | 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`); |
8 | 11 | }; |
9 | 12 |
|
10 | 13 | export const intro = (title = '', opts?: CommonOptions) => { |
11 | 14 | 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`); |
13 | 18 | }; |
14 | 19 |
|
15 | 20 | export const outro = (message = '', opts?: CommonOptions) => { |
16 | 21 | 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`); |
18 | 25 | }; |
0 commit comments