From fe01ead0234181478e862a30aa49d48c261e42a8 Mon Sep 17 00:00:00 2001 From: Akis Kesoglou Date: Thu, 15 Mar 2018 10:24:25 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20getting=20window=20size=20when=20there?= =?UTF-8?q?=E2=80=99s=20no=20TTY=20attached?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Type: patch --- lib/utils/tty.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/utils/tty.coffee b/lib/utils/tty.coffee index 22610ce1..20f9dae5 100644 --- a/lib/utils/tty.coffee +++ b/lib/utils/tty.coffee @@ -2,9 +2,9 @@ windowSize = {} updateWindowSize = -> - size = require('window-size').get() - windowSize.width = size.width - windowSize.height = size.height + size = require('window-size')?.get() + windowSize.width = size?.width + windowSize.height = size?.height process.stdout.on('resize', updateWindowSize) @@ -13,7 +13,8 @@ module.exports = (stream = process.stdout) -> updateWindowSize() currentWindowSize = -> - # always return a copy + # always return a copy. + # width/height can be undefined if no TTY. width: windowSize.width height: windowSize.height