mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04: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:
1 parent
e2cf2f0fda
commit
14af167209
2 files changed
+67
-68
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user