@@ -2,7 +2,7 @@ import process from 'node:process';
22import type { Writable } from 'node:stream' ;
33import { stripVTControlCharacters as strip } from 'node:util' ;
44import { getColumns } from '@clack/core' ;
5- import { wrapAnsi } from 'fast-wrap-ansi' ;
5+ import { type Options as WrapAnsiOptions , wrapAnsi } from 'fast-wrap-ansi' ;
66import color from 'picocolors' ;
77import {
88 type CommonOptions ,
@@ -22,13 +22,17 @@ export interface NoteOptions extends CommonOptions {
2222const defaultNoteFormatter = ( line : string ) : string => color . dim ( line ) ;
2323
2424const wrapWithFormat = ( message : string , width : number , format : FormatFn ) : string => {
25- const wrapMsg = wrapAnsi ( message , width ) . split ( '\n' ) ;
25+ const opts : WrapAnsiOptions = {
26+ hard : true ,
27+ trim : false ,
28+ } ;
29+ const wrapMsg = wrapAnsi ( message , width , opts ) . split ( '\n' ) ;
2630 const maxWidthNormal = wrapMsg . reduce ( ( sum , ln ) => Math . max ( strip ( ln ) . length , sum ) , 0 ) ;
2731 const maxWidthFormat = wrapMsg
2832 . map ( format )
2933 . reduce ( ( sum , ln ) => Math . max ( strip ( ln ) . length , sum ) , 0 ) ;
3034 const wrapWidth = width - ( maxWidthFormat - maxWidthNormal ) ;
31- return wrapAnsi ( message , wrapWidth ) ;
35+ return wrapAnsi ( message , wrapWidth , opts ) ;
3236} ;
3337
3438export const note = ( message = '' , title = '' , opts ?: NoteOptions ) => {
0 commit comments