1+ import process from 'node:process' ;
12import type { Writable } from 'node:stream' ;
23import { stripVTControlCharacters as strip } from 'node:util' ;
4+ import { wrapAnsi } from 'fast-wrap-ansi' ;
35import color from 'picocolors' ;
46import {
57 type CommonOptions ,
@@ -10,22 +12,22 @@ import {
1012 S_CORNER_TOP_RIGHT ,
1113 S_STEP_SUBMIT ,
1214} from './common.js' ;
13- import { wrapAnsi } from "fast-wrap-ansi" ;
14- import process from "node:process" ;
1515
1616export interface NoteOptions extends CommonOptions {
1717 format ?: ( line : string ) => string ;
1818}
1919
2020const defaultNoteFormatter = ( line : string ) : string => color . dim ( line ) ;
2121
22- const wrapWithFormat = ( message : string , width : number , format : NoteOptions [ " format" ] ) : string => {
23- const wrapMsg = wrapAnsi ( message , width ) . split ( "\n" ) ;
22+ const wrapWithFormat = ( message : string , width : number , format : NoteOptions [ ' format' ] ) : string => {
23+ const wrapMsg = wrapAnsi ( message , width ) . split ( '\n' ) ;
2424 const maxWidthNormal = wrapMsg . reduce ( ( sum , ln ) => Math . max ( strip ( ln ) . length , sum ) , 0 ) ;
25- const maxWidthFormat = wrapMsg . map ( format ) . reduce ( ( sum , ln ) => Math . max ( strip ( ln ) . length , sum ) , 0 ) ;
25+ const maxWidthFormat = wrapMsg
26+ . map ( format )
27+ . reduce ( ( sum , ln ) => Math . max ( strip ( ln ) . length , sum ) , 0 ) ;
2628 const wrapWidth = width - ( maxWidthFormat - maxWidthNormal ) ;
2729 return wrapAnsi ( message , wrapWidth ) ;
28- }
30+ } ;
2931
3032export const note = ( message = '' , title = '' , opts ?: NoteOptions ) => {
3133 const output : Writable = opts ?. output ?? process . stdout ;
0 commit comments