@oclif/table 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/table.js +2 -2
- package/lib/utils.js +1 -1
- package/package.json +1 -1
package/lib/table.js
CHANGED
|
@@ -37,7 +37,7 @@ function determineConfiguredWidth(providedWidth, columns = process.stdout.column
|
|
|
37
37
|
* This allows us to use the minimum width required to display the table if the configured width is too small.
|
|
38
38
|
*/
|
|
39
39
|
function determineWidthToUse(columns, configuredWidth) {
|
|
40
|
-
const tableWidth = columns.map((c) => c.width).reduce((a, b) => a + b) + columns.length + 1;
|
|
40
|
+
const tableWidth = columns.map((c) => c.width).reduce((a, b) => a + b, 0) + columns.length + 1;
|
|
41
41
|
return tableWidth < configuredWidth ? configuredWidth : tableWidth;
|
|
42
42
|
}
|
|
43
43
|
function determineTruncatePosition(overflow) {
|
|
@@ -306,7 +306,7 @@ const createStdout = () => {
|
|
|
306
306
|
const stripped = stripAnsi(f);
|
|
307
307
|
return stripped !== '' && stripped !== '\n';
|
|
308
308
|
})
|
|
309
|
-
.at(-1);
|
|
309
|
+
.at(-1) ?? '';
|
|
310
310
|
return stdout;
|
|
311
311
|
};
|
|
312
312
|
class Output {
|
package/lib/utils.js
CHANGED
|
@@ -67,7 +67,7 @@ export function getColumns(config, headings) {
|
|
|
67
67
|
};
|
|
68
68
|
});
|
|
69
69
|
const numberOfBorders = widths.length + 1;
|
|
70
|
-
const calculateTableWidth = (widths) => widths.map((w) => w.width + w.padding * 2).reduce((a, b) => a + b) + numberOfBorders;
|
|
70
|
+
const calculateTableWidth = (widths) => widths.map((w) => w.width + w.padding * 2).reduce((a, b) => a + b, 0) + numberOfBorders;
|
|
71
71
|
// If the table is too wide, reduce the width of the largest column as little as possible to fit the table.
|
|
72
72
|
// At most, it will reduce the width to the length of the column's header plus padding.
|
|
73
73
|
// If the table is still too wide, it will reduce the width of the next largest column and so on
|