4 * window-size <https://github.com/jonschlinkert/window-size>
6 * Copyright (c) 2014-2015 Jon Schlinkert
7 * Licensed under the MIT license.
10 var tty = require('tty');
12 module.exports = (function () {
16 if (tty.isatty(1) && tty.isatty(2)) {
17 if (process.stdout.getWindowSize) {
18 width = process.stdout.getWindowSize(1)[0];
19 height = process.stdout.getWindowSize(1)[1];
20 } else if (tty.getWindowSize) {
21 width = tty.getWindowSize()[1];
22 height = tty.getWindowSize()[0];
23 } else if (process.stdout.columns && process.stdout.rows) {
24 height = process.stdout.rows;
25 width = process.stdout.columns;
28 Error('window-size could not get size with tty or process.stdout.');
31 return {height: height, width: width};