UNPKG

780 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function termwidth(stream) {
4 if (!stream.isTTY) {
5 return 80;
6 }
7 const width = stream.getWindowSize()[0];
8 if (width < 1) {
9 return 80;
10 }
11 if (width < 40) {
12 return 40;
13 }
14 return width;
15}
16const columns = global['columns'];
17let stdtermwidth = termwidth(process.stdout);
18let errtermwidth = termwidth(process.stderr);
19process.stdout.on('resize', () => {
20 stdtermwidth = termwidth(process.stdout);
21});
22process.stderr.on('resize', () => {
23 errtermwidth = termwidth(process.stderr);
24});
25exports.default = {
26 get errtermwidth() {
27 return columns || errtermwidth;
28 },
29 get stdtermwidth() {
30 return columns || stdtermwidth;
31 },
32};