summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/cli-width/index.js
blob: f158f362be149a10d2c84dc16755f6fb008f049c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';

exports = module.exports = cliWidth;
exports.defaultWidth = 0;

function cliWidth() {
  if (process.stdout.getWindowSize) {
    return process.stdout.getWindowSize()[0];
  }
  else {
    var tty = require('tty');

    if (tty.getWindowSize) {
      return tty.getWindowSize()[1];
    }
    else {
      if (process.env.CLI_WIDTH) {
        var width = parseInt(process.env.CLI_WIDTH, 10);

        if (!isNaN(width)) {
          return width;
        }
      }

      return exports.defaultWidth;
    }
  }
};