(message = '', title = '')
| 223 | |
| 224 | const strip = (str: string) => str.replace(ansiRegex(), ''); |
| 225 | export const note = (message = '', title = '') => { |
| 226 | const lines = `\n${message}\n`.split('\n'); |
| 227 | const titleLen = strip(title).length; |
| 228 | const len = |
| 229 | Math.max( |
| 230 | lines.reduce((sum, ln) => { |
| 231 | ln = strip(ln); |
| 232 | return ln.length > sum ? ln.length : sum; |
| 233 | }, 0), |
| 234 | titleLen |
| 235 | ) + 2; |
| 236 | const msg = lines |
| 237 | .map((ln) => `${gray(S_BAR)} ${white(ln)}${' '.repeat(len - strip(ln).length)}${gray(S_BAR)}`) |
| 238 | .join('\n'); |
| 239 | process.stdout.write( |
| 240 | `${gray(S_BAR)}\n${green(S_STEP_SUBMIT)} ${reset(title)} ${gray( |
| 241 | S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT |
| 242 | )}\n${msg}\n${gray(S_CONNECT_LEFT + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n` |
| 243 | ); |
| 244 | }; |
| 245 | // End of used code from clack |
no test coverage detected
searching dependent graphs…