mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: support narrow terminal windows for messages (#18714)
This patch starts using a message box that's not really a box and thus is better behaving on a narrow-width terminals. Before: <img width="744" alt="image" src="https://user-images.githubusercontent.com/746130/201216551-abbac0f8-71b4-413f-9f4e-159c7123ef3d.png"> After: <img width="745" alt="image" src="https://user-images.githubusercontent.com/746130/201216504-25257727-06c8-4ae9-8557-a2d937b7ca0b.png"> Signed-off-by: Andrey Lushnikov <aslushnikov@gmail.com> Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
This commit is contained in:
parent
db826c9c8c
commit
23171c5037
@ -191,12 +191,10 @@ export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL
|
||||
|
||||
export function wrapInASCIIBox(text: string, padding = 0): string {
|
||||
const lines = text.split('\n');
|
||||
const maxLength = Math.max(...lines.map(line => line.length));
|
||||
return [
|
||||
'╔' + '═'.repeat(maxLength + padding * 2) + '╗',
|
||||
...lines.map(line => '║' + ' '.repeat(padding) + line + ' '.repeat(maxLength - line.length + padding) + '║'),
|
||||
'╚' + '═'.repeat(maxLength + padding * 2) + '╝',
|
||||
].join('\n');
|
||||
const maxLineLength = Math.max(...lines.map(line => line.length));
|
||||
const separatorLength = process.stdout.columns || maxLineLength;
|
||||
const separator = '═'.repeat(separatorLength);
|
||||
return [separator, ...lines, separator, ''].join('\n');
|
||||
}
|
||||
|
||||
export function isFilePayload(value: any): boolean {
|
||||
|
Loading…
x
Reference in New Issue
Block a user