From 007ebdadb1d53cff14456abcf2a9d0a09fc59066 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Sat, 30 Mar 2024 19:35:11 -0400 Subject: [PATCH] Center that launch logo --- packages/backend/src/services/WebServerService.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/WebServerService.js b/packages/backend/src/services/WebServerService.js index 7ea74a33..4c987074 100644 --- a/packages/backend/src/services/WebServerService.js +++ b/packages/backend/src/services/WebServerService.js @@ -355,7 +355,17 @@ class WebServerService extends BaseService { } else break; } if ( last_logo ) { - console.log('\x1B[34;1m' + last_logo.txt + '\x1B[0m'); + const lines = last_logo.txt.split('\n'); + const width = process.stdout.columns; + const pad = (width - last_logo.sz) / 2; + const asymmetrical = pad % 1 !== 0; + const pad_left = Math.floor(pad); + const pad_right = Math.ceil(pad) + (asymmetrical ? 1 : 0); + for ( let i = 0 ; i < lines.length ; i++ ) { + lines[i] = ' '.repeat(pad_left) + lines[i] + ' '.repeat(pad_right); + } + const txt = lines.join('\n'); + console.log('\n\x1B[34;1m' + txt + '\x1B[0m\n'); } } }