11import process from 'node:process' ;
22import type { Writable } from 'node:stream' ;
3- import { getColumns } from '@clack/core' ;
3+ import { getColumns , settings } from '@clack/core' ;
44import stringWidth from 'fast-string-width' ;
55import { type Options as WrapAnsiOptions , wrapAnsi } from 'fast-wrap-ansi' ;
66import color from 'picocolors' ;
99 S_BAR ,
1010 S_BAR_H ,
1111 S_CONNECT_LEFT ,
12+ S_CORNER_BOTTOM_LEFT ,
1213 S_CORNER_BOTTOM_RIGHT ,
1314 S_CORNER_TOP_RIGHT ,
1415 S_STEP_SUBMIT ,
@@ -35,6 +36,7 @@ const wrapWithFormat = (message: string, width: number, format: FormatFn): strin
3536
3637export const note = ( message = '' , title = '' , opts ?: NoteOptions ) => {
3738 const output : Writable = opts ?. output ?? process . stdout ;
39+ const hasGuide = ( opts ?. withGuide ?? settings . withGuide ) !== false ;
3840 const format = opts ?. format ?? defaultNoteFormatter ;
3941 const wrapMsg = wrapWithFormat ( message , getColumns ( output ) - 6 , format ) ;
4042 const lines = [ '' , ...wrapMsg . split ( '\n' ) . map ( format ) , '' ] ;
@@ -52,9 +54,11 @@ export const note = (message = '', title = '', opts?: NoteOptions) => {
5254 ( ln ) => `${ color . gray ( S_BAR ) } ${ ln } ${ ' ' . repeat ( len - stringWidth ( ln ) ) } ${ color . gray ( S_BAR ) } `
5355 )
5456 . join ( '\n' ) ;
57+ const leadingBorder = hasGuide ? `${ color . gray ( S_BAR ) } \n` : '' ;
58+ const bottomLeft = hasGuide ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT ;
5559 output . write (
56- `${ color . gray ( S_BAR ) } \n ${ color . green ( S_STEP_SUBMIT ) } ${ color . reset ( title ) } ${ color . gray (
60+ `${ leadingBorder } ${ color . green ( S_STEP_SUBMIT ) } ${ color . reset ( title ) } ${ color . gray (
5761 S_BAR_H . repeat ( Math . max ( len - titleLen - 1 , 1 ) ) + S_CORNER_TOP_RIGHT
58- ) } \n${ msg } \n${ color . gray ( S_CONNECT_LEFT + S_BAR_H . repeat ( len + 2 ) + S_CORNER_BOTTOM_RIGHT ) } \n`
62+ ) } \n${ msg } \n${ color . gray ( bottomLeft + S_BAR_H . repeat ( len + 2 ) + S_CORNER_BOTTOM_RIGHT ) } \n`
5963 ) ;
6064} ;
0 commit comments