Fix getting window size when there’s no TTY attached

Change-Type: patch
This commit is contained in:
Akis Kesoglou 2018-03-15 10:24:25 +02:00
parent 229c105d0c
commit fe01ead023

View File

@ -2,9 +2,9 @@
windowSize = {} windowSize = {}
updateWindowSize = -> updateWindowSize = ->
size = require('window-size').get() size = require('window-size')?.get()
windowSize.width = size.width windowSize.width = size?.width
windowSize.height = size.height windowSize.height = size?.height
process.stdout.on('resize', updateWindowSize) process.stdout.on('resize', updateWindowSize)
@ -13,7 +13,8 @@ module.exports = (stream = process.stdout) ->
updateWindowSize() updateWindowSize()
currentWindowSize = -> currentWindowSize = ->
# always return a copy # always return a copy.
# width/height can be undefined if no TTY.
width: windowSize.width width: windowSize.width
height: windowSize.height height: windowSize.height