3 * https://github.com/jonschlinkert/window-size
\r
5 * Copyright (c) 2014 Jon Schlinkert
\r
6 * Licensed under the MIT license.
\r
9 const tty = require('tty')
\r
11 module.exports = (function() {
\r
15 if(tty.isatty(1) && tty.isatty(2)) {
\r
16 if(process.stdout.getWindowSize) {
\r
17 width = process.stdout.getWindowSize(1)[0];
\r
18 height = process.stdout.getWindowSize(1)[1];
\r
19 } else if (tty.getWindowSize) {
\r
20 width = tty.getWindowSize()[1];
\r
21 height = tty.getWindowSize()[0];
\r
22 } else if (process.stdout.columns && process.stdout.rows) {
\r
23 height = process.stdout.columns;
\r
24 width = process.stdout.rows;
\r
27 new Error('Error: could not get window size with tty or process.stdout');
\r