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 = {}
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