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:
Jithil P Ponnan authored and GitHub committed 2023-10-28 01:14:22 +00:00
1 parent e2cf2f0fda
commit 14af167209
2 files changed
+67 -68

No files matched your search

+2 -3
View File
@@ -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;
}