Code coverage report for cli-width/index.js

Statements: 100% (13 / 13)      Branches: 100% (8 / 8)      Functions: 100% (1 / 1)      Lines: 100% (13 / 13)      Ignored: none     

All files » cli-width/ » index.js
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 29    1 1   1 6 1     5   5 1     4 2   2 1       3        
'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;
    }
  }
};