mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
lib: align console.table row to the left
PR-URL: https://github.com/nodejs/node/pull/50135 Fixes: https://github.com/nodejs/node/issues/50117 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
e2cf2f0fda
commit
14af167209
|
|
@ -40,11 +40,10 @@ const renderRow = (row, columnWidths) => {
|
|||
for (let i = 0; i < row.length; i++) {
|
||||
const cell = row[i];
|
||||
const len = getStringWidth(cell);
|
||||
const needed = (columnWidths[i] - len) / 2;
|
||||
const needed = (columnWidths[i] - len);
|
||||
// round(needed) + ceil(needed) will always add up to the amount
|
||||
// of spaces we need while also left justifying the output.
|
||||
out += StringPrototypeRepeat(' ', needed) + cell +
|
||||
StringPrototypeRepeat(' ', MathCeil(needed));
|
||||
out += cell + StringPrototypeRepeat(' ', MathCeil(needed));
|
||||
if (i !== row.length - 1)
|
||||
out += tableChars.middle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ test([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], `
|
|||
|
||||
{
|
||||
const line = '─'.repeat(79);
|
||||
const header = `${' '.repeat(37)}name${' '.repeat(40)}`;
|
||||
const header = `name${' '.repeat(77)}`;
|
||||
const name = 'very long long long long long long long long long long long ' +
|
||||
'long long long long';
|
||||
test([{ name }], `
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user