Skip to content

Commit ff6067d

Browse files
committed
Make sure table width is integer
- In some environments, and depending on how the console window is resized, maxWidth can be an odd number. This makes maxWidth / 2 a decimal and cli-table2 fails with `RangeError: Invalid array length`. - Fixes #40
1 parent 8ddb85d commit ff6067d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/models/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ var Logger = CoreObject.extend({
1818

1919
flush: function() {
2020
var maxWidth = process.stdout.columns - 4;
21+
var halfWidth = Math.floor(maxWidth / 2);
2122
var table = new Table({
2223
head: ['Source', 'Destination'],
23-
colWidths: [maxWidth / 2, maxWidth / 2]
24+
colWidths: [halfWidth, halfWidth]
2425
});
2526

2627

0 commit comments

Comments
 (0)