Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80765 views
1
/*
2
* window-size
3
* https://github.com/jonschlinkert/window-size
4
*
5
* Copyright (c) 2014 Jon Schlinkert
6
* Licensed under the MIT license.
7
*/
8
9
const tty = require('tty')
10
11
module.exports = (function() {
12
var width;
13
var height;
14
15
if(tty.isatty(1) && tty.isatty(2)) {
16
if(process.stdout.getWindowSize) {
17
width = process.stdout.getWindowSize(1)[0];
18
height = process.stdout.getWindowSize(1)[1];
19
} else if (tty.getWindowSize) {
20
width = tty.getWindowSize()[1];
21
height = tty.getWindowSize()[0];
22
} else if (process.stdout.columns && process.stdout.rows) {
23
height = process.stdout.columns;
24
width = process.stdout.rows;
25
}
26
} else {
27
new Error('Error: could not get window size with tty or process.stdout');
28
}
29
return {
30
height: height,
31
width: width
32
}
33
})();
34