Skip to content

Commit f405166

Browse files
committed
feat(@clack/prompts): give stop and note success status
1 parent 45ee73b commit f405166

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/prompts/src/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
565565
};
566566

567567
const strip = (str: string) => str.replace(ansiRegex(), '');
568-
export const note = (message = '', title = '') => {
568+
export const note = (message = '', title = '', code: number = 0) => {
569569
const lines = `\n${message}\n`.split('\n');
570570
const titleLen = strip(title).length;
571571
const len =
@@ -584,8 +584,12 @@ export const note = (message = '', title = '') => {
584584
)}`
585585
)
586586
.join('\n');
587+
const step =
588+
code === 0
589+
? color.green(S_STEP_SUBMIT)
590+
: color.green(S_SUCCESS)
587591
process.stdout.write(
588-
`${color.gray(S_BAR)}\n${color.green(S_STEP_SUBMIT)} ${color.reset(title)} ${color.gray(
592+
`${color.gray(S_BAR)}\n${step} ${color.reset(title)} ${color.gray(
589593
S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT
590594
)}\n${msg}\n${color.gray(S_CONNECT_LEFT + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n`
591595
);
@@ -700,6 +704,8 @@ export const spinner = () => {
700704
? color.green(S_STEP_SUBMIT)
701705
: code === 1
702706
? color.red(S_STEP_CANCEL)
707+
: code === 2
708+
? color.green(S_SUCCESS)
703709
: color.red(S_STEP_ERROR);
704710
process.stdout.write(cursor.move(-999, 0));
705711
process.stdout.write(erase.down(1));

0 commit comments

Comments
 (0)