1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function 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 | }
|
16 | const columns = global['columns'];
|
17 | let stdtermwidth = termwidth(process.stdout);
|
18 | let errtermwidth = termwidth(process.stderr);
|
19 | process.stdout.on('resize', () => {
|
20 | stdtermwidth = termwidth(process.stdout);
|
21 | });
|
22 | process.stderr.on('resize', () => {
|
23 | errtermwidth = termwidth(process.stderr);
|
24 | });
|
25 | exports.default = {
|
26 | get errtermwidth() {
|
27 | return columns || errtermwidth;
|
28 | },
|
29 | get stdtermwidth() {
|
30 | return columns || stdtermwidth;
|
31 | },
|
32 | };
|