| 23 | const defaultNoteFormatter = (line: string): string => line; |
| 24 | |
| 25 | const wrapWithFormat = (message: string, width: number, format: FormatFn): string => { |
| 26 | const opts: WrapAnsiOptions = { |
| 27 | hard: true, |
| 28 | trim: false, |
| 29 | }; |
| 30 | const wrapMsg = wrapAnsi(message, width, opts).split('\n'); |
| 31 | const maxWidthNormal = wrapMsg.reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0); |
| 32 | const maxWidthFormat = wrapMsg.map(format).reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0); |
| 33 | const wrapWidth = width - (maxWidthFormat - maxWidthNormal); |
| 34 | return wrapAnsi(message, wrapWidth, opts); |
| 35 | }; |
| 36 | |
| 37 | export const note = (message = '', title = '', opts?: NoteOptions) => { |
| 38 | const output: Writable = opts?.output ?? process.stdout; |