mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-30 02:28:51 +00:00
Fix getting window size when there’s no TTY attached
Change-Type: patch
This commit is contained in:
parent
229c105d0c
commit
fe01ead023
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user